ERROR BUILDING .EXE. Can someone help.

This is a discussion on ERROR BUILDING .EXE. Can someone help. within the Game Programming forums, part of the General Programming Boards category; I'm trying to make a basic 2D tile engine with allegro and I'm getting this error: SVCRT.lib(crtexew.obj) : error LNK2001: ...

  1. #1
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57

    ERROR BUILDING .EXE. Can someone help.

    I'm trying to make a basic 2D tile engine with allegro and I'm getting this error:

    SVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
    tileEngine.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.


    Does anyone haev any ideas that could help me resolve this problem.

    Thanks in advance.
    Last edited by TWIXMIX; 12-23-2004 at 09:57 AM.
    Learning C++
    Programmer in training

  2. #2
    Epo
    Epo is offline
    Registered User
    Join Date
    Jun 2003
    Posts
    361
    To me, it seems that you're trying to make a Win32 Application, but you're still treating it as a console application maybe...

    It seems to not be able to find WinMain(). (Some source would help alot)

    Specifically the function you're using as an Entry-Point into your program...

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    In the link tab of your project settings, look for the project options box. Change the part that says /subsystem:console to /subsystem:windows. Next, switch to the C/C++ tab, and delete the line _CONSOLE from the Preprocessor definitions section, and replace it with _WINDOWS.

    If memory serves me correctly, that should be enough to switch your project from a console app to a win32 app.

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Did you put END_OF_MAIN() at the end of your main function?
    Woop?

  5. #5
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    Here is the source. It is a basic 2D tile engine.

    Code:
    #include <allegro.h>
    #include <string>
    #include <fstream>
    using namespace std;
    
    void drawMap(BITMAP *b, int sx, int sy);
    void loadMap(string s);
    
    int map[100][100];
    
    BITMAP *buffer;
    BITMAP *tiles[3];
    BITMAP *player;
    
    void main(void)
    {
    	allegro_init();
    	install_keyboard();
    	install_timer();
    	set_color_depth(8);
    	set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0);
    	PALLETE pal;
    	tiles[0] = load_bitmap("textures/grass.gif", pal);
    	tiles[1] = load_bitmap("textures/tree.gif", pal);
    	tiles[2] = load_bitmap("textures/bush.gif", pal);
    	player = load_bitmap("sprites/sprite1.gif", pal);
    	buffer = create_bitmap(320, 240);
    	loadMap("maps/map1.txt");
    	
    	int x = 50, y = 50;
    	int xs = 0, ys = 0;
    	int up = false, down = false, left = false, right = false;
    
    	while(!key[KEY_ESC]) {
    		drawMap(buffer, x, y);
    		draw_sprite(buffer, player, (320 / 2), (240 / 2));
    		blit(buffer, screen, 0, 0, 0, 0, 16, 16);
    		poll_keyboard();
    
    		if(key[KEY_UP])		up = true;		else up = false;
    		if(key[KEY_DOWN])	down = true;	else down = false;
    		if(key[KEY_LEFT])	left = true;	else left = false;
    		if(key[KEY_RIGHT])	right = true;	else right = false;
    		if (up | down | left | right) {
    			for(int i = 0; i != 16; i++) {
    				if(up)		ys -= i;
    				if(down)	ys += i;
    				if(left)	xs -= i;
    				if(right)	xs += i;
    				drawMap(buffer, x, y);
    				draw_sprite(buffer, player, (320 / 2), (240 / 2));
    				blit(buffer, screen, 0, 0, xs - 16, ys - 16, 16, 16);
    			}
    			xs = 0;
    			ys = 0;
    
    			if(up)		y--;
    			if(down)	y++;
    			if(left)	x--;
    			if(right)	x++;
    			drawMap(buffer, x, y);
    			draw_sprite(buffer, player, (320 / 2), (240 / 2));
    			blit(buffer, screen, 0, 0, 0, 0, 16, 16);
    		}
    	}
    }
    END_OF_MAIN();
    
    void drawMap(BITMAP *b, int sx, int sy)
    {
    	for(int x = sx; x != (((240/26)+2)+sy); x++) {
    		for(int y = sy; y != (((240/16)+2)+sy); y++) {
    			blit(tiles[map[x][y]], buffer, 0, 0, (x * 16), (y * 16), 16, 16);
    		}
    	}
    }
    
    void loadMap(string s)
    {
    	ifstream file_in;
    	file_in.open(s.c_str());
    
    	int total_x = 0;
    	int total_y = 0;
    	file_in >> total_x >> total_y;
    
    	for(int x = 0; x != total_x; x++) {
    		for (int y = 0; y != total_y; y++) {
    			file_in >> map[x][y];
    		}
    	}
    	file_in.close();
    }
    It now compiles, but when I run the program it closes right away. Now I have to figure out how to fix that little problem.
    Learning C++
    Programmer in training

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Here we go.
    1. void main(void)
      • This should be int main(void), main returns an int.


    2. BITMAP *load_bitmap(const char *filename, RGB *pal);

      Loads a bitmap from a file. The palette data will be stored in the second parameter, which should be an array of 256 RGB structures. At present this function supports BMP, LBM, PCX, and TGA files, determining the type from the file extension.
      • This is from the allegro manuals I don't see gif in there anywhere


    3. Always check to see if your your bitmap loaded properly.
      Code:
      if(bitmapName == NULL)
      {
        //print out some sort of message and quit
      }
    Woop?

  7. #7
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    oops... I forgot about the whole non-gif thing.

    Thanks alot.

    I'll test that out again.
    Learning C++
    Programmer in training

  8. #8
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    OKay I have got it all going and I set up a little thing to tell me if the textures are loading correctly.

    They're not.
    THere is now reason, that I can see, which would cause my textures to not load properly.

    Now I gotta find the problem.
    Last edited by TWIXMIX; 12-23-2004 at 10:44 PM.
    Learning C++
    Programmer in training

  9. #9
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Well,
    Are they in your current directory?
    Woop?

  10. #10
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    they are in the textures folder , which is right off of where the .exe is.
    I already tried putting them in the same directory as the executable but I still got nothing.
    Learning C++
    Programmer in training

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Could you possible zip up your source, pics and txt files and post them I would like to take a look.
    Woop?

  12. #12
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    There you go.
    I had to take some stuff out but it should still work.
    Attached Files Attached Files
    Learning C++
    Programmer in training

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fopen can't open .exe?
    By fanoliv in forum C Programming
    Replies: 11
    Last Post: 04-05-2011, 03:24 PM
  2. Replies: 13
    Last Post: 12-09-2008, 10:09 AM
  3. .exe size with MinGW
    By Stabbsy in forum C++ Programming
    Replies: 3
    Last Post: 11-16-2006, 05:07 AM
  4. Changing program from .cpp to .exe
    By BIt_toRreNt in forum C++ Programming
    Replies: 6
    Last Post: 02-16-2005, 03:24 PM
  5. Problem creating .exe files
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 03-22-2002, 01:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21