为什么编译的时候没有问题,可是build的时候却出现问题呢?谢谢大家帮忙了
jltt 2004-11-16 12:34:27 //如下为编译错误:
/*
--------------------Configuration: t3d - Win32 Debug--------------------
Linking...
t.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
t.obj : error LNK2001: unresolved external symbol _DirectDrawCreate@12
Debug/t3d.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
t3d.exe - 3 error(s), 0 warning(s)
*/
//如下为代码
#include<windows.h>
#include<windowsx.h>
#include <ddraw.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0X8000) ? 1:0)
HINSTANCE hinstance_app;
HWND main_window_handle;
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW7 lpdd7 = NULL;
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
int Game_Init(void *parms=NULL);
int Game_Main(void *parms =NULL);
int Game_Shutdown(void *parms = NULL);
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
HDC hdc;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName=NULL;
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
//save instance in global
hinstance_app=hinstance;
if(!RegisterClassEx(&winclass))
{
return 0;
}
if(!(hwnd=CreateWindowEx(NULL,WINDOW_CLASS_NAME,
"T3D Game Console Version 1.0",
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
0,0,
400,300,
NULL,
NULL,
hinstance,
NULL)))
return 0;
// MessageBox(NULL,"d","t",MB_OK);
main_window_handle = hwnd;
Game_Init();
while(TRUE)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT)
{
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Game_Main();
}
Game_Shutdown();
return (msg.wParam);
}
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch(msg)
{
case WM_CREATE:
{
return 0;
}
case WM_PAINT:
{
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default:break;
};
return DefWindowProc(hwnd,msg,wparam,lparam);
}
int Game_Init(void *parms)
{
/*directx9.0不支持这种写法
if(FAILED(DirectDrawCreateEx(NULL,(void **)&lpdd,IID_IDirectDraw7,NULL)))
return 0;
*/
if (FAILED(DirectDrawCreate(NULL,&lpdd,NULL)))
return 0;
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7,(LPVOID* )&lpdd7)))
return 0;
if(FAILED(lpdd7->SetCooperativeLevel(main_window_handle,DDSCL_NORMAL)))
return 0;
return 1;
}
int Game_Main(void *parms)
{
if(KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle,WM_CLOSE,0,0);
return 1;
}
int Game_Shutdown(void *parms)
{
if(lpdd7)
{
lpdd7->Release();
lpdd7 = NULL;
}
return 1;
}