I have a header file that holds global BITMAP variables and I've included them in 2 CPP files, that is the gameEngine.cpp and Main.cpp[/font][font=arial, verdana, tahoma, sans-serif][size=2]I've posted this before, but I guess I did so in the wrong forum as I got no replies.
Here is my Bitmaps.h file
[source lang='cpp']
#ifndef BITMAPS_H
#define BITMAPS_H
#include
extern BITMAP *buffer;
extern BITMAP *p_right;
extern BITMAP *p_left;
extern BITMAP *p_jump_left;
extern BITMAP *p_jump_right;[source='gameEngine.cpp']if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) { MessageBox(NULL, "Allegro failed to initialize the graphics!", "Error!", MB_OK | MB_ICONEXCLAMATION); exit(1); } set_window_title("TITLE REMOVED"); BITMAP *buffer = create_bitmap(640, 480); BITMAP *p_right = load_bitmap("gfx\\p_right.bmp", NULL); BITMAP *p_left = load_bitmap("gfx\\p_left.bmp", NULL); BITMAP *p_jump_left = load_bitmap("gfx\\p_jump_left.bmp", NULL); BITMAP *p_jump_right = load_bitmap("gfx\\p_jump_right.bmp", NULL); BITMAP *menu_background = load_bitmap("data\\menu_background.bmp", NULL); BITMAP *menu_play = load_bitmap("data\\play.bmp", NULL); BITMAP *menu_info = load_bitmap("data\\info.bmp", NULL); BITMAP *menu_exit = load_bitmap("data\\exit.bmp", NULL);[/source]
extern BITMAP *menu_background;
extern BITMAP *menu_play;
extern BITMAP *menu_info;
extern BITMAP *menu_exit;
#endif[/source]
[font="arial, verdana, tahoma, sans-serif"]Sorry for long post,
And here is a snippet of my gameEngine.cpp in the 'init()' function
[source lang="cpp"]
set_window_title("Halo: The Untold");
BITMAP *buffer = create_bitmap(640, 480);
BITMAP *p_right = load_bitmap("gfx\\p_right.bmp", NULL);
BITMAP *p_left = load_bitmap("gfx\\p_left.bmp", NULL);
BITMAP *p_jump_left = load_bitmap("gfx\\p_jump_left.bmp", NULL);
BITMAP *p_jump_right = load_bitmap("gfx\\p_jump_right.bmp", NULL);
BITMAP *menu_background = load_bitmap("data\\menu_background.bmp", NULL);
BITMAP *menu_play = load_bitmap("data\\play.bmp", NULL);
BITMAP *menu_info = load_bitmap("data\\info.bmp", NULL);
BITMAP *menu_exit = load_bitmap("data\\exit.bmp", NULL);
show_mouse(screen);
[/source]
And my main.cpp's use of these BITMAPs
[source lang="cpp"]
switch(g.state)
{
case MENUSCREEN:
//making menuscreen background
draw_sprite(buffer, menu_background, 0, 0);
masked_blit(menu_play, buffer, 0, 0, 300, 300, 189, 50);
masked_blit(menu_info, buffer, 0, 0, 300, 350, 189, 50);
masked_blit(menu_exit, buffer, 0, 0, 300, 400, 189, 50);
/*play = 300, 300 info = 300, 350 exit = 300, 400*/
break;
case GAME:
break;
case CREDITS:
break;
}
[/source]
Here are the list of confusing linker errors
<div>Linking...
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_exit" (?menu_exit@@3PAUBITMAP@@A)
Main.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_exit" (?menu_exit@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_info" (?menu_info@@3PAUBITMAP@@A)
Main.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_info" (?menu_info@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_play" (?menu_play@@3PAUBITMAP@@A)
Main.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_play" (?menu_play@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_background" (?menu_background@@3PAUBITMAP@@A)
Main.obj : error LNK2001: unresolved external symbol "struct BITMAP * menu_background" (?menu_background@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * p_jump_right" (?p_jump_right@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * p_jump_left" (?p_jump_left@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * p_right" (?p_right@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * p_left" (?p_left@@3PAUBITMAP@@A)
gameEngine.obj : error LNK2001: unresolved external symbol "struct BITMAP * buffer" (?buffer@@3PAUBITMAP@@A)
Main.obj : error LNK2001: unresolved external symbol "struct BITMAP * buffer" (?buffer@@3PAUBITMAP@@A)
Thanks ahead for reply :][/font][/font]