Use CDisplay class in DxSDK Sample COmmon File,but can't link it.

Started by
0 comments, last by qfly 21 years, 6 months ago
Hi, I write this code.I can compile it in VC6 + Dx8.1 but I can''t link it,the error message is: CDisplay is a class in ddutil.h(common file in DX Sample SDK),and I add these lib to project: ddraw.lib dxguid.lib dxerr8.lib winmm.lib but it still has following errors. Who can help me? Thanks. --------------------Configuration: InitDirectDraw - Win32 Release-------------------- Linking... InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: __thiscall CDisplay::~CDisplay(void)" (??1CDisplay@@QAE@XZ) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: long __thiscall CDisplay::CreateSurfaceFromText(class CSurface * *,struct HFONT__ *,char *,unsigned long,unsigned long)" (?CreateSurfaceFromText@CDisplay@@QAEJPAPAVCSurface@@PAU HFONT__@@PADKK@Z) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: long __thiscall CDisplay::CreateFullScreenDisplay(struct HWND__ *,unsigned long,unsigned long,unsigned long)" (?CreateFullScreenDisplay@CDisplay@@QAEJPAUHWND__@@KKK@Z) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: __thiscall CDisplay::CDisplay(void)" (??0CDisplay@@QAE@XZ) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: __thiscall CSurface::~CSurface(void)" (??1CSurface@@QAE@XZ) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: long __thiscall CDisplay:resent(void)" (?Present@CDisplay@@QAEJXZ) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: long __thiscall CDisplay::Blt(unsigned long,unsigned long,class CSurface *,struct tagRECT *)" (?Blt@CDisplay@@QAEJKKPAVCSurface@@PAUtagRECT@@@Z) InitDirectDraw.obj : error LNK2001: unresolved external symbol "public: long __thiscall CDisplay::Clear(unsigned long)" (?Clear@CDisplay@@QAEJK@Z) Release/InitDirectDraw.exe : fatal error LNK1120: 8 unresolved externals Error executing link.exe. InitDirectDraw.exe - 9 error(s), 0 warning(s) //================== The following is the code. //================== #define STRICT #include <windows.h> #include <ddraw.h> #include <mmsystem.h> #include <ddutil.h> #define SAFE_DELETE(p) {if(p) {delete (p);(p) = NULL;}} #define SAFE_RELEASE(p) {if(p) {(p)->Release();(p) = NULL;}} #define ERMSG(x) MessageBox(hWnd,x,"DirectDraw Program",MB_OK); CDisplay* g_pDisplay = NULL; CSurface* g_pTextSurface = NULL; BOOL g_bActive; LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM); HRESULT WinInit(HINSTANCE hInst,int nCmdShow,HWND* phWnd); HRESULT InitDirectDraw(HWND hWnd); VOID FreeDirectDraw(); HRESULT DisplayFrame(); int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG msg; HWND hWnd; if(FAILED(WinInit(hInst,nCmdShow,&hWnd))) return FALSE; if(FAILED(InitDirectDraw(hWnd))) { if(g_pDisplay) g_pDisplay->GetDirectDraw()->SetCooperativeLevel(NULL,DDSCL_NORMAL); ERMSG("DirectDraw Init Failed.The Sample Will now Exit!"); return FALSE; } while(TRUE) { if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { if(0 == GetMessage(&msg,NULL,0,0)) return (int)msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); } else { if(g_bActive) { if(FAILED(DisplayFrame())) { SAFE_DELETE(g_pDisplay); ERMSG("Displaying the next Frame failed!The Program will now Exit!") return FALSE; } } else WaitMessage(); } } } HRESULT WinInit(HINSTANCE hInst,int nCmdShow,HWND* phWnd) { WNDCLASS wc; HWND hWnd; wc.lpszClassName = TEXT("Hello,DirectX 8"); wc.lpfnWndProc = MainWndProc; wc.style = CS_VREDRAW | CS_HREDRAW; wc.hInstance = hInst; wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; if(RegisterClass(&wc)==0) return E_FAIL; hWnd = CreateWindowEx(0,TEXT("Hello,DirectX 8 !"), TEXT("DirectDraw Text View"), WS_POPUP,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInst,NULL); if(hWnd == NULL) return E_FAIL; ShowWindow(hWnd,nCmdShow); UpdateWindow(hWnd); *phWnd = hWnd; return S_OK; } HRESULT InitDirectDraw(HWND hWnd) { HRESULT hr; g_pDisplay = new CDisplay(); if(FAILED(hr = g_pDisplay->CreateFullScreenDisplay(hWnd,800,600,16))) { ERMSG("The Display Card does not Support it!"); return hr; } if(FAILED(hr = g_pDisplay->CreateSurfaceFromText(&g_pTextSurface,NULL,"Hello,DirectX 8!",RGB(0,0,0),RGB(255,255,0)))) return hr; return S_OK; } VOID FreeDirectDraw() { SAFE_DELETE(g_pTextSurface); SAFE_DELETE(g_pDisplay); } LRESULT CALLBACK MainWndProc(HWND hWnd,UINT msg,WPARAM wparam,LPARAM lparam) { switch(msg) { case WM_KEYDOWN: PostMessage(hWnd,WM_CLOSE,0,0); return 0L; case WM_SIZE: if(SIZE_MAXHIDE == wparam || SIZE_MINIMIZED == wparam) g_bActive = FALSE; else g_bActive = TRUE; break; case WM_SYSCOMMAND: switch(wparam) { case SC_MOVE: case SC_SIZE: case SC_MAXIMIZE: case SC_MINIMIZE: return TRUE; } break; case WM_DESTROY: FreeDirectDraw(); PostQuitMessage(0); return 0L; } return DefWindowProc(hWnd,msg,wparam,lparam); } HRESULT DisplayFrame() { HRESULT hr; g_pDisplay->Clear(0); g_pDisplay->Blt(0,0,g_pTextSurface,NULL); if(FAILED(hr = g_pDisplay->Present())) return hr; } //==================
Advertisement
Sounds like you need to include the source file (ddutil.cpp) in your project.

This topic is closed to new replies.

Advertisement