几天来我一直在学习 DirectX,但遇到了一个问题。我一直在关注一个书籍示例,并解决了几个出现的烦人问题,但未能解决我最近的一个问题。编译器指出,每当我尝试编译时,我都有一个未解析的外部符号。这是下面的错误代码。
1>game.obj : error LNK2019: unresolved external symbol "struct IDirect3DSurface9 * __cdecl
LoadSurface(char *,unsigned long)" (?LoadSurface@@YAPAUIDirect3DSurface9@@PADK@Z) referenced in
function "int __cdecl Game_Init(struct HWND__ *)" (?Game_Init@@YAHPAUHWND__@@@Z)
1>C:\Users\Christopher\Documents\Visual Studio 2008\Projects\Work\Debug\Work.exe : fatal error
LNK1120: 1 unresolved externals
我正在运行:[编译器:Visual Studios 2008] [操作系统:Windows 7 64bit Professional]
这是代码示例以及它似乎发生的位置。(我希望我提供了足够的信息)
LPDIRECT3DSURFACE9 kitty_image[7];
SPRITE kitty;
LPDIRECT3DSURFACE9 back;
//timing variable
long start = GetTickCount();
//initializes the game
int Game_Init(HWND hwnd)
{
char s[20];
int n;
//set random number seed
srand(time(NULL));
//load the sprite animation
for (n=0; n<6; n++)
{
sprintf(s, "cat%d.bmp",n+1);
kitty_image[n] = LoadSurface(s, D3DCOLOR_XRGB(255,0,255));
if (kitty_image[n] == NULL)
return 0;
}
back = LoadSurface("background.bmp", NULL );
//initialize the sprite's properties
kitty.x = 100;
kitty.y = 150;
kitty.width = 96;
kitty.height = 96;
kitty.curframe = 0;
kitty.lastframe = 5;
kitty.animdelay = 2;
kitty.animcount = 0;
kitty.movex = 8;
kitty.movey = 0;
//return okay
return 1;
}
我已将 d3d9.lib 和 d3dx9.lib 链接到我的项目,并包含了我知道的所有必需的头文件(d3d9.h、d3dx9.h)。任何帮助是极大的赞赏!提前致谢!!!