undefined reference to DirectDrawCreate@12

Started by
17 comments, last by marcin - rem 18 years, 7 months ago
C:/Dev-Cpp/Projects/DirectX Image/myframe.cpp:32: undefined reference to `DirectDrawCreate@12' I know that libraries should be included, and I did it with ddraw.lib from the dxsdk\library directory, but still I've got this linker error. So what should I link.
Advertisement
Just a thought... sometimes includes can get a bit anal.
Make sure you're including DDraw.h in the file that references DirectDrawCreate, and also try adding DDraw.h and DDraw.cpp to your project (this can solve some weird linker errors).
Join us at: http://www.blade2k.net/piracysucks/to help stop game piracy!
I can add ddraw.h to my project, but not ddraw.cpp, this is source file not delivered with directx sdk. After adding ddraw.h still nothing.
Strange.. That looks like a fastcall name decoration (where 12 stands for the number of bytes of arguments).
You could get the compiler to come up with such a name in C if you changed the default calling convention, though I don't see how it could happen in C++ without manually adding a function declaration.
Still.. Including <ddraw.h> should be enough unless perhaps one of Microsoft's strange include guards is acting up, try changing the order of includes around a bit to see if it helps.
...wait a minute... did you include dxguid.lib? and place ddraw.lib and dxguid.lib before your other lib includes? Not doing that can cause it to act up too.
Join us at: http://www.blade2k.net/piracysucks/to help stop game piracy!
I linked my project with dxquid.lib and I also tried to change their order but still nothing. I'm still getting the same linking error.
I'm really confused now
You could try declaring it yourself, it should clash with the other incorrect declaration and show you where it is.
Here's the correct version:
extern "C" HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );

Or you could link it in dynamically through LoadLibrary and GetProcAddress, or even import it as a COM interface.

[Edited by - doynax on September 13, 2005 2:22:32 PM]
doynax I don't know if that can help, becouse the problem is not with compiler but linker, linker doesn't see the directdrawcreate function in the library. This problem often occurs when the priopriate library is not linked. But I checked your idea, the result is still the same. What do you do when you create directx program. I just added the libraries from the dxsdk\lib folder and called directdraw. Please help me people. I tried to search something on google. But there is handfull of pages where somebody had this problem. And they solved it by adding ddraw.lib, so I'm doing it and no result. maaaaaaaaaaaaan I'm tired.
Hmm, please list the libraries you included, and the version of DirectDraw you are using(Adding in your DirectDrawCreate code line would help too). That'll give us a better idea of what's going on.

Join us at: http://www.blade2k.net/piracysucks/to help stop game piracy!

This topic is closed to new replies.

Advertisement