Unresolved external symbol error when compiling my game (VC++ 2010/ Allegr 4)

Started by
2 comments, last by ISDCaptain01 10 years, 7 months ago

Im done coding my game, I have it split in 3 separate files

- my header file which contains the class, function prototypes, and extern variables

- the implementation .cpp file which implements all the functions and gives a value to the extern variables

- the main.cpp file which included the main function to get the game running.

When I compile I get a bunch of LNK 20001: unresolved external symbol errors

Heres my code:

header file


#pragma once
#include <allegro.h>
#include "mappyal.h"
#include <iostream>
using namespace std;

//Must run at 640 x 480
#define WIDTH 640
#define HEIGHT 480

//Color macros
#define WHITE makecol(255, 255, 255)
#define GRAY makecol(60, 60, 60)
#define RED makecol(200, 0, 0)

//Game macros
#define MAX_ENEMIES 20
#define MAX_BULLETS 20
#define MAX_EXPLOSIONS 10
#define BOTTOM 48000 - HEIGHT


//Sprite class
class SPRITE
{
public:
	int dir, alive;
	int x, y;
	int width, height;
	int xspeed, yspeed;
	int xdelay, ydelay;
	int xcount, ycount;
	int curframe, maxframe, animdir;
	int framecount, framedelay;
};

//y offset in pixel
extern int yoffset;

//Player variables
extern int firecount;
extern int firedelay;
extern int health;
extern int score;

//Bitmaps and sprites
extern BITMAP *buffer;
extern BITMAP *temp;
extern BITMAP *explosion_images[6];
extern SPRITE *explosions[MAX_EXPLOSIONS];
extern BITMAP *bigexp_images[7];
extern SPRITE *bigexp;
extern BITMAP *player_images[3];
extern SPRITE *player;
extern BITMAP *bullet_images[2];
extern SPRITE *bullets[MAX_BULLETS];
extern BITMAP *enemy_plane_images[3];
extern SPRITE *enemy_planes[MAX_ENEMIES];
extern BITMAP *progress, *bar;
extern BITMAP *bonus_shot_image;
extern SPRITE *bonus_shot;


//Function prototypes
BITMAP *grabframe(BITMAP *source, int width, int height, 
	            int startx, int starty, int columns, int frame);
void loadsprite();
int inside(int x, int y, int left, int top, int right, int bottom);
void updatesprite(SPRITE *spr);
void startexplosion(int x, int y);
void updateexplosions();
void updatebonuses();
void updatebullet(SPRITE *spr);
void updatebullets();
void fireatenemy();
void bouncex_warpy(SPRITE *spr);
void displayprogress(int life);
void updateenemyplanes();
void updatescroller();
void updateplayer();
void checkinput();
void initialize();

implementation file:


#include "warbirds.h"


//y offset in pixel
int yoffset = BOTTOM;

//Player variables
int firecount = 0;
int firedelay = 60;
int health = 25;
int score = 0;


//Grabs the frame of a sprite sheet
BITMAP *grabframe(BITMAP *source, int width, int height, 
	            int startx, int starty, int columns, int frame)
{
	BITMAP *temp = create_bitmap(width, height);
	int x = startx + (frame % columns) * width;
	int y = starty + (frame / columns) * height;

	blit(source, temp, x, y, 0, 0, width, height);
	return temp;
}


//Load all the sprites into the game
void loadsprite()
{
	//counter variable
	int n;

	//load the progress bar
	temp = load_bitmap("progress.bmp", NULL);
	progress = grabframe(temp, 130, 14, 0, 0, 1, 0);
	bar = grabframe(temp, 6, 10, 130, 2, 1, 0);
	destroy_bitmap(temp);

	//load the bonus shot
	bonus_shot_image = load_bitmap("bonushot.bmp", NULL);
	bonus_shot = new SPRITE;
	bonus_shot->alive = 0;
	bonus_shot->x = 0;
	bonus_shot->y = 0;
	bonus_shot->width = bonus_shot_image->w;
	bonus_shot->height = bonus_shot_image->h;
	bonus_shot->xdelay = 0;
	bonus_shot->ydelay = 2;
	bonus_shot->xcount = 0;
	bonus_shot->ycount = 0;
	bonus_shot->xspeed = 0;
	bonus_shot->yspeed = 1;  //moving down the screen
	bonus_shot->curframe = 0;
	bonus_shot->maxframe = 0;
	bonus_shot->framecount = 0;
	bonus_shot->framedelay = 0;

	
	//Load the player 
	temp = load_bitmap("p38.bmp", NULL);
	for(n = 0; n < 3; n++)
	{
		player_images[n] = grabframe(temp, 64, 64, 0, 0, 3, n);
	}
	destroy_bitmap(temp);

	player = new SPRITE;
	player->x = 320 - 32; //middle of screen
	player->y = 400;  //nearly bottom of screen
	player->width = player_images[0]->w;
	player->height = player_images[0]->h;
	player->xdelay = 1;
	player->ydelay = 0;
	player->xcount = 0;
	player->ycount = 0;
	player->xspeed = 0;
	player->yspeed = 0;
	player->curframe = 0;
	player->maxframe = 2;
	player->framecount = 0;
	player->framedelay = 10;
	player->animdir = 1;

	//Load the bullets
	bullet_images[0] = load_bitmap("bullets.bmp", NULL);

	for(n = 0; n < MAX_BULLETS; n++)
	{
		bullets[n] = new SPRITE;
		bullets[n]->alive = 0;
		bullets[n]->x = 0;
		bullets[n]->y = 0;
		bullets[n]->width = bullet_images[0]->w;
		bullets[n]->height = bullet_images[0]->h;
		bullets[n]->xdelay = 0;
		bullets[n]->ydelay = 0;
		bullets[n]->xcount = 0;
		bullets[n]->ycount = 0;
		bullets[n]->xspeed = 0;
		bullets[n]->yspeed = -2;  //moving up the screen
		bullets[n]->curframe = 0;
		bullets[n]->maxframe = 0;
		bullets[n]->framecount = 0;
		bullets[n]->framedelay = 0;
		bullets[n]->animdir = 0;
	}

	//load the enemy planes
	temp = load_bitmap("enemyplane1.bmp", NULL);
	for(n = 0; n < 3; n++)
	{
		enemy_plane_images[n] = grabframe(temp, 32, 32, 0, 0, 3, n);
	}
	destroy_bitmap(temp);

	for(n = 0; n < MAX_ENEMIES; n++)
	{
		enemy_planes[n] = new SPRITE;
		enemy_planes[n]->alive = 0;
		enemy_planes[n]->x = rand() % 100 + 50;
		enemy_planes[n]->y = 0;
		enemy_planes[n]->width = enemy_plane_images[0]->w;
		enemy_planes[n]->height = enemy_plane_images[0]->h;
		enemy_planes[n]->xdelay = 4;
		enemy_planes[n]->ydelay = 4;
		enemy_planes[n]->xcount = 0;
		enemy_planes[n]->ycount = 0;
		enemy_planes[n]->xspeed = (rand() % 2 - 3);
		enemy_planes[n]->yspeed = 1; //moving down the screen
		enemy_planes[n]->curframe = 0;
		enemy_planes[n]->maxframe = 2;
		enemy_planes[n]->framecount = 0;
		enemy_planes[n]->framedelay = 10;
		enemy_planes[n]->animdir = 1;
	}

	//Load the explosions
	temp = load_bitmap("explosion.bmp", NULL);
	for(n = 0; n < 6; n++)
	{
		explosion_images[n] = grabframe(temp, 32, 32, 0, 0, 6, n);
	}
	destroy_bitmap(temp);

	for(n = 0; n < MAX_EXPLOSIONS; n++)
	{
		explosions[n] = new SPRITE;
		explosions[n]->alive = 0;
		explosions[n]->x = 0;
		explosions[n]->y = 0;
		explosions[n]->width = explosion_images[0]->w;
		explosions[n]->height = explosion_images[0]->h;
		explosions[n]->xdelay = 0;
		explosions[n]->ydelay = 8;
		explosions[n]->xcount = 0;
		explosions[n]->ycount = 0;
		explosions[n]->yspeed = -1; //moving up the screen
		explosions[n]->xspeed = 0;
		explosions[n]->curframe = 0;
		explosions[n]->maxframe = 5;
		explosions[n]->framecount = 0;
		explosions[n]->framedelay = 15;
		explosions[n]->animdir = 1;
	}


	//load the big explosions
	temp = load_bitmap("bigexplosion.bmp", NULL);
	for(n = 0; n < 7; n++)
	{
		bigexp_images[n] = grabframe(temp, 64, 64, 0, 0, 7, n);
	}
	destroy_bitmap(temp);

	bigexp = new SPRITE;
	bigexp->alive = 0;
	bigexp->x = 0;
	bigexp->y = 0;
	bigexp->width = bigexp_images[0]->w;
	bigexp->height = bigexp_images[0]->h;
	bigexp->xdelay = 0;
	bigexp->ydelay = 8;
	bigexp->xcount = 0;
	bigexp->ycount = 0;
	bigexp->xspeed = 0;
	bigexp->yspeed = -1; //moves up the screen
	bigexp->curframe = 0;
	bigexp->maxframe = 6;
	bigexp->framecount = 0;
	bigexp->framedelay = 10;
	bigexp->animdir = 1;
}

//detects if a sprite is inside another one (collision detection)
int inside(int x, int y, int left, int top, int right, int bottom)
{
	if(x > left && x < right && y > top && y < bottom)
		return 1;
	else
		return 0;
}



//animates and moves the sprites
void updatesprite(SPRITE *spr)
{
	//update the x position
	if(++spr->xcount > spr->xdelay)
	{
		spr->xcount = 0;
		spr->x += spr->xspeed;
	}

	//update the y position
	if(++spr->ycount > spr->ydelay)
	{
		spr->ycount = 0;
		spr->y += spr->yspeed;
	}

	//update the frame based on animdir
	if(++spr->framecount > spr->framedelay)
	{
		spr->framecount = 0;
		if(spr->animdir == -1)
		{
			if(--spr->curframe < 0)
				spr->curframe = spr->maxframe;
		}
		if(spr->animdir == 1)
		{
			if(++spr->curframe > spr->maxframe)
				spr->curframe = 0;
		}
	}
}


void startexplosion(int x, int y)
{
	int n;
	for(n = 0; n < MAX_EXPLOSIONS; n++)
	{
		//check to see if the explosions are inactive
		if(!explosions[n]->alive)
		{
			//make the explosions active
			explosions[n]->alive++;
			explosions[n]->x = x;
			explosions[n]->y = y;
			break;
		}
	}

	//launch bonus shot if ready
	if(!bonus_shot->alive)
	{
		bonus_shot->alive++;
		bonus_shot->x = x;
		bonus_shot->y = y;
	}
}

//responsible for drawing and moving the explosions
void updateexplosions()
{
	int n, c = 0;
	for(n = 0; n < MAX_EXPLOSIONS; n++)
	{
		if(explosions[n]->alive)
		{
			c++;
			updatesprite(explosions[n]);
			draw_sprite(buffer, explosion_images[explosions[n]->curframe],
				        explosions[n]->x, explosions[n]->y);
			
			//once the explosion is complete, kill it
			if(explosions[n]->curframe >= explosions[n]->maxframe)
			{
				explosions[n]->curframe = 0;
				explosions[n]->alive = 0;
			}
		}
	}
	textprintf(buffer, font, 0, 430, WHITE, "explosions %d", c);

	//update the big "player" explosion if needed
	if(bigexp->alive)
	{
		updatesprite(bigexp);

		draw_sprite(buffer, bigexp_images[bigexp->curframe], bigexp->x, bigexp->y);
		if(bigexp->curframe >= bigexp->maxframe)
		{
			bigexp->curframe = 0;
			bigexp->alive = 0;
		}
	}
}


//responsible for drawing and moving the bonuses
void updatebonuses()
{
	int x, y, x1, y1, x2, y2;

	//add more bonuses(yes , YOU!)

	//update bonus shot if alive
	if(bonus_shot->alive)
	{
		updatesprite(bonus_shot);
		draw_sprite(buffer, bonus_shot_image, bonus_shot->x, bonus_shot->y);
		if(bonus_shot->y > HEIGHT)
			bonus_shot->alive = 0;

		//see if player got bonus shot
		x = bonus_shot->x + bonus_shot->width/2;
		y = bonus_shot->y + bonus_shot->height/2;
		x1 = player->x;
		y1 = player->y;
		x2 = player->x + player->width;
		y2 = player->y + player->height;

		if(inside(x, y, x1, y1, x2, y2))
		{
			//increase firing rate
			if(firedelay > 20)
				firedelay -= 2;
			bonus_shot->alive = 0;
		}
	}
}

void updatebullet(SPRITE *spr)
{
	int n, x, y;
	int x1, y1, x2, y2;

	//move the bullets
	updatesprite(spr);

	//check bounds
	if(spr->y < 0)
	{
		spr->alive = 0;
		return;
	}

	for(n = 0; n < MAX_ENEMIES; n++)
	{
		if(enemy_planes[n]->alive)
		{
			//find the center of the bullets
			x = spr->x + spr->width/2;
			y = spr->y + spr->height/2;

			//get enemy bounding rectangle
			x1 = enemy_planes[n]->x;
			y1 = enemy_planes[n]->y;
			x2 = enemy_planes[n]->width;
			y2 = enemy_planes[n]->height;

			//check for collisions
			if(inside(x, y, x1, y1, x2, y2))
			{
				enemy_planes[n]->alive = 0;
				spr->alive = 0;
				startexplosion(spr->x+16, spr->y);
				score += 2;
				break;
			}
		}
	}
}

void updatebullets()
{
	int n;

	//update/drawbullets
	for(n = 0;  n < MAX_BULLETS; n++)
	{
		if(bullets[n]->alive)
		{
			updatebullet(bullets[n]);
			draw_sprite(buffer, bullet_images[0], bullets[n]->x, bullets[n]->y);
		}
	}
}


//shoots bullets from the players plane
void fireatenemy()
{
	int n;
	for(n = 0; n < MAX_BULLETS; n++)
	{
		if(!bullets[n]->alive)
		{
			bullets[n]->alive++;
			bullets[n]->x = player->x;
			bullets[n]->y = player->y;
			return;
		}
	}
}


void bouncex_warpy(SPRITE *spr)
{
	//if x position of sprite goes beyond left side of screen
	//bounce it back
	if(spr->x < 0 - spr->width)
	{
		spr->x = 0 - spr->width+1;

		//make sprite go in opposite direction
		spr->xspeed *= -1;
	}

	//if it goes beyond right side of screen
	else if(spr->x > SCREEN_W)
	{
		spr->x = SCREEN_W - spr->xspeed;

		//go the opposite direction
		spr->xspeed *= -1;
	}

	//warp y if plane has passed player
	if(spr->y > yoffset + 2000)
	{
		//respawn enemy plane
		spr->y = yoffset - 1000 - rand() % 1000;
		spr->alive++;
		spr->x = rand() % WIDTH;
	}

	//warps y from bottom to the top of the level
	if(spr->y < 0)
	{
		spr->y = 0;
	}
	else if( spr->y > 48000)
	{
		spr->y = 0;
	}
}


void displayprogress(int life)
{
	int n;

	//draw the empty bar
	draw_sprite(buffer, progress, 490, 15);

	//fill up the bar with energy
	for(n = 0; n < life; n++)
	{
		draw_sprite(buffer, bar, 492+n*5, 17);
	}
}

void updateenemyplanes()
{
	int n;
	int c = 0;

	//update/draw enemy planes
	for(n = 0; n < MAX_ENEMIES; n++)
	{
		if(enemy_planes[n]->alive)
		{
			c++;
			updatesprite(enemy_planes[n]);
			bouncex_warpy(enemy_planes[n]);

			//is plane visible on screen
			if(enemy_planes[n]->y > yoffset-32 &&
				enemy_planes[n]->y < yoffset + HEIGHT + 32)
			{
				//draw enemy planes on screen
				draw_sprite(buffer, enemy_plane_images[enemy_planes[n]->curframe], 
					        enemy_planes[n]->x, enemy_planes[n]->y - yoffset);
			}
		}

		//reset plane
		else
		{
			enemy_planes[n]->alive++;
			enemy_planes[n]->x = rand() % 100 + 50;
			enemy_planes[n]->y = yoffset - 2000 + rand() % 2000;
		}

	}

	textprintf_ex(buffer, font, 0, 470, WHITE, -1, "Enemies %d", c);
}


void updatescroller()
{
	//make sure it doesnt scroll beyond map edge
	if(yoffset < 5)
	{
		//level is over
		yoffset = 5;
		textout_centre_ex(buffer, font, "END OF LEVEL", SCREEN_W/2, SCREEN_H/2, WHITE, -1);
	}

	if(yoffset > BOTTOM)
		yoffset = BOTTOM;

	//scroll map up 1 pixel
	yoffset -= 1;

	//Draw the map with single layer
	MapDrawBG(buffer, 0, yoffset, 0, 0, SCREEN_W-1, SCREEN_H-1);
}


void updateplayer()
{
	int n, x, y, x1, y1, x2, y2;

	//update/draw player sprite
	updatesprite(player);
    draw_sprite(buffer, player_images[player->curframe], player->x, player->y);

	//check for collision
	x = player->x + player->width/2;
	y = player->y + player->height/2;
	for(n = 0; n < MAX_ENEMIES; n++)
	{
		if(enemy_planes[n]->alive)
		{
			x1 = enemy_planes[n]->x;
			y1 = enemy_planes[n]->y - yoffset;
			x2 = x1 + enemy_planes[n]->width;
			y2 = y1 + enemy_planes[n]->height;
			if(inside(x, y, x1, y1, x2, y2))
			{
				enemy_planes[n]->alive = 0;
				if(health > 0) 
					health--;
				bigexp->alive++;
				bigexp->x = player->x;
				bigexp->y = player->y;
				score++;
			}
		}
	}
}


void checkinput()
{
	//check for keyboard input
	if(key[KEY_UP])
	{
		player->y -= 1;
		if(player->y < 100)
			player->y = 100;
	}
	if(key[KEY_DOWN])
	{
		player->y += 1;
		if(player->y > HEIGHT - 65)
			player->y = HEIGHT - 65;
	}
	if(key[KEY_LEFT])
	{
		player->x -= 1;
		if(player->x < 0)
			player->x = 0;
	}
	if(key[KEY_RIGHT])
	{
		player->x += 1;
		if(player->x > WIDTH - 65)
			player->x = WIDTH-65;
		
	}
	if(key[KEY_SPACE])
	{
		if(firecount > firedelay)
		{
			firecount = 0;
			fireatenemy();
		}
	}
}




void initialize()
{
	//initialize the program
	allegro_init();
	install_timer();
	install_keyboard();
	set_color_depth(16);
	srand(time(NULL));

	//set the screen
	int ret = set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
	if(ret != 0)
	{
		allegro_message("Error loading screen");
		return;
	}

	//Create the double buffer
	buffer = create_bitmap(SCREEN_W, SCREEN_H);
	clear_bitmap(buffer);

	//Load the mappy file
	int check = MapLoad("level1.fmp");
	if(check != 0)
	{
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Could not load level1.fmp");
		return;
	}


	
}

	











and finally my main.cpp file


#include "warbirds.h"


//interrupt handeler
//Timer variables
volatile int counter;
volatile int ticks;
volatile int framerate;


//displays the stats
void displaystats()
{
	//display some status information
	textprintf_ex(buffer, font, 0, 420, WHITE, -1, "Firing rate %d", firedelay);
	textprintf_ex(buffer, font, 0, 440, WHITE, -1, "Counter %d", counter);
	textprintf_ex(buffer, font, 0, 450, WHITE, -1, "Yoffset %d", yoffset);
	textprintf_ex(buffer, font, 0, 460, WHITE, -1, "Framerate %d", framerate);

	//display score
	textprintf_ex(buffer, font, 22, 22, GRAY, -1, "SCORE: %d", score);
	textprintf_ex(buffer, font, 20, 20, RED, -1, "SCROE: %d", score);
}

//calculate framerate every second
void timer1()
{
	counter++;
	framerate = ticks;
	ticks = 0;
	rest(2);
}
END_OF_FUNCTION(timer1)







int main()
{
	int n;

	//Intialize the game
	initialize();

	//indetify variables used by interupt funtion
	LOCK_VARIABLE(counter);
	LOCK_VARIABLE(framerate);
	LOCK_VARIABLE(ticks);
	LOCK_FUNCTION(timer1);

	//create new interupt handler
	install_int(timer1, 1000);

	//Load in all the sprites 
	loadsprite();

    //Start the main game loop
	while(!key[KEY_ESC])
	{
		//check if the player is interacting with the controls
		checkinput();

		//draw/update the map to the buffer
		updatescroller();

		//update and draw the enemy and player
		updateplayer();
		updateenemyplanes();

		//draw and update the bullets 
		updatebullets();

		//draw and update the explosions
		updateexplosions();

		//draw and update bonuses and
		//apply its effects on players if it collideds
		updatebonuses();

		//display health
		displayprogress(health);

		//display the stats
		displaystats();

		//blit the double buffer
		acquire_screen();
		blit(buffer, screen, 0, 0, 0, 0, SCREEN_W-1, SCREEN_H-1);
		release_screen();

		ticks++;
		firecount++;
	}

	//delete mappy level
	MapFreeMem();

	//delete bitmaps
	destroy_bitmap(buffer);
	destroy_bitmap(progress);
	destroy_bitmap(bar);

	for(n = 0; n < 6; n++)
	{
		destroy_bitmap(explosion_images[n]);
	}
	for(n = 0; n < 3; n++)
	{
		destroy_bitmap(player_images[n]);
		destroy_bitmap(bullet_images[n]);
		destroy_bitmap(enemy_plane_images[n]);
	}

	//delete the sprite pointers
	delete player;
	for(n = 0; n < MAX_EXPLOSIONS; n++)
	{
		delete explosions[n];
	}
	for(n = 0; n < MAX_BULLETS; n++)
	{
		delete bullets[n];
	}
	for(n = 0; n < MAX_ENEMIES; n++)
	{
		delete enemy_planes[n];
	}


	allegro_exit();
	return 0;

}
END_OF_MAIN()

heres a list of the errors

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * buffer" (?buffer@@3PAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * buffer" (?buffer@@3PAUBITMAP@@A)

1>main.obj : error LNK2001: unresolved external symbol "class SPRITE * * enemy_planes" (?enemy_planes@@3PAPAVSPRITE@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "class SPRITE * * enemy_planes" (?enemy_planes@@3PAPAVSPRITE@@A)

1>main.obj : error LNK2001: unresolved external symbol "class SPRITE * * bullets" (?bullets@@3PAPAVSPRITE@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "class SPRITE * * bullets" (?bullets@@3PAPAVSPRITE@@A)

1>main.obj : error LNK2001: unresolved external symbol "class SPRITE * * explosions" (?explosions@@3PAPAVSPRITE@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "class SPRITE * * explosions" (?explosions@@3PAPAVSPRITE@@A)

1>main.obj : error LNK2001: unresolved external symbol "class SPRITE * player" (?player@@3PAVSPRITE@@A)

1>warbirds.obj : error LNK2019: unresolved external symbol "class SPRITE * player" (?player@@3PAVSPRITE@@A) referenced in function "void __cdecl loadsprite(void)" (?loadsprite@@YAXXZ)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * * enemy_plane_images" (?enemy_plane_images@@3PAPAUBITMAP@@A)

1>warbirds.obj : error LNK2019: unresolved external symbol "struct BITMAP * * enemy_plane_images" (?enemy_plane_images@@3PAPAUBITMAP@@A) referenced in function "void __cdecl loadsprite(void)" (?loadsprite@@YAXXZ)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * * bullet_images" (?bullet_images@@3PAPAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * * bullet_images" (?bullet_images@@3PAPAUBITMAP@@A)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * * player_images" (?player_images@@3PAPAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * * player_images" (?player_images@@3PAPAUBITMAP@@A)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * * explosion_images" (?explosion_images@@3PAPAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * * explosion_images" (?explosion_images@@3PAPAUBITMAP@@A)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * bar" (?bar@@3PAUBITMAP@@A)

1>warbirds.obj : error LNK2019: unresolved external symbol "struct BITMAP * bar" (?bar@@3PAUBITMAP@@A) referenced in function "void __cdecl loadsprite(void)" (?loadsprite@@YAXXZ)

1>main.obj : error LNK2001: unresolved external symbol "struct BITMAP * progress" (?progress@@3PAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * progress" (?progress@@3PAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "class SPRITE * bigexp" (?bigexp@@3PAVSPRITE@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * * bigexp_images" (?bigexp_images@@3PAPAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "class SPRITE * bonus_shot" (?bonus_shot@@3PAVSPRITE@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * bonus_shot_image" (?bonus_shot_image@@3PAUBITMAP@@A)

1>warbirds.obj : error LNK2001: unresolved external symbol "struct BITMAP * temp" (?temp@@3PAUBITMAP@@A)

1>C:\Users\user\Desktop\Warbirds Pacifica\Debug\Warbirds Pacifica.exe : fatal error LNK1120: 16 unresolved externals

Advertisement
Global variables declared as extern in your header files need to be defined in a source file. So if you have an extern BITMAP * buffer; in your header file, in one source file you need to put a BITMAP * buffer; at namespace scope (not inside a function or class definition).

Are you sure you have added those file to your project?

alright, I resolved the issue. thank you

This topic is closed to new replies.

Advertisement