DirectX linking issues in VC++ 6.0

Started by
9 comments, last by darrenhall 20 years, 1 month ago
Hopefully this will be an easy question to answer... I''m getting linking errors when compiling my program dealing with the DirectX libs. My IDE is VC++ 6.0 and my platform is Win XP pro. Here''s the code - DEFINES ////////////////////// #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <ddraw.h> ////////////////////////////// // WinMain() // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { MSG msg; LPDIRECTDRAW7 lpdd = NULL; // dd7 object // create IDirectDraw interface 7.0 object if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL))) return(0); // main event loop while(TRUE) { // if there is a message in the queue, get it if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // test if this is a quit message if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if } // end while // exit program return(msg.wParam); } // // end WinMain() ////////////////////////////// Here''s the error - --------------------Configuration: test - Win32 Debug-------------------- Compiling... test.cpp Linking... test.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7 Debug/test.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. test.exe - 2 error(s), 0 warning(s) Here''s my libs and path info - *under the Project Settings link tab: Object/library modules - kernel32.lib user32.lib gdi32.lib winmm.lib ddraw.lib dsound.lib dinput.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib *under the Tools/Options directories tab: Show directories for "Library files" - C:\DXSDK\LIB C:\Program Files\Microsoft Visual Studio\VC98\LIB C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB Anyone know why I''m not resolving my DirectX IID variable?
Advertisement
Did you also set the Include Directory to C:\DXSDK\INCLUDE ???
Yes I did.

*under the Tools/Options directories tab:
Show directories for "Include files" -

C:\DXSDK\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE



Is the path to the library correct?
If your problem is what I think it is, you can fix this in one of two ways: 1) in exactly one source file, before you include the DirectX header, #define INIT_GUID. 2) link against dxguid.lib.

Probably the dxguid.lib method is less error-prone.
Ok, you need to link to dxguid.lib... like SiCrane said. I tested it and it worked.

~Thek

[edited by - Thek on March 7, 2004 3:50:30 PM]
"There are three kinds of people in the world: those who can count, and those who can't."
I noticed you are linking to a number of libraries normally inherited from the project defaults. It isn''t a big deal, but you can normally get away without most of those.

I generally link with theses for Win32 D3D Apps:
dxguid.lib dinput8.lib d3dx9.lib d3d9.lib winmm.lib user32.lib gdi32.lib advapi32.lib
(in your case, substitute d3dx9.lib and d3d9.lib for ddraw.lib)

~Thek
"There are three kinds of people in the world: those who can count, and those who can't."
Excellent!

That was it. I included dxguid.lib in the link path and it compiles fine.

Thanks!

Just out of curiosity... what does it need out of dxguid to link properly? I thought the IID was defined in the ddraw file, right?
Yes, you''re right Thek.

Thats mostly because they were there by default, and I''m not sure what was really ''needed'' and what wasn''t so I just left them.

Most of my C/C++ experience is from a UNIX background and I haven''t done much for windows, so I''m still getting used to the environment and which libs, etc. are necessary and which really aren''t.
It only contains an extern reference to the IID. No storage is actually allocated for the IID until you link against dxguid.lib or #define INIT_GUID in a source file.

This topic is closed to new replies.

Advertisement