Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

darrenhall

DirectX linking issues in VC++ 6.0

This topic is 5367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!