Stupid Linking Error

Started by
2 comments, last by JSCFaith 23 years, 9 months ago
Hey all, Well im makeing a small program and I keep getting this error when I link: main4.obj : error LNK2005: _DDLoadBitmap already defined in ddutil.obj main4.obj : error LNK2005: _DDReLoadBitmap already defined in ddutil.obj main4.obj : error LNK2005: _DDCopyBitmap already defined in ddutil.obj main4.obj : error LNK2005: _DDLoadPalette already defined in ddutil.obj main4.obj : error LNK2005: _DDColorMatch already defined in ddutil.obj main4.obj : error LNK2005: _DDSetColorKey already defined in ddutil.obj main4.obj : error LNK2001: unresolved external symbol _DirectDrawCreateEx@16 Debug/ghfghf.exe : fatal error LNK1120: 1 unresolved externals Although it is many errors, they are pretty much the same thing. When I include ddutil.cpp in my project it does this, my book told me to include the .cpp instead of the .h, dont know why. Well this is what I keep getting, so I tired including the ddutil.h, but then I kept getting all these incorrect syntax stuff, all the incorrect syntax is in the .h and not in my code, so I dont know what to do. It looks fine to me. James, Later
Advertisement

The errors you are getting is because more than one source file defines the same functions.

It sounds as if your both compiling the ddutil.cpp file and #include''ing it in main4.cpp.

You should include the .cpp file in your project (i.e. so that it is compiled and linked in with the rest of the files) and NOT include it in any other source file (using #include).
The .h file on the other hand should be #include''ed in any file that calls a function in ddutil.cpp .
Also link with the dx libs (ddraw.lib and dxguid.lib should be enough if you are only using DirectDraw).
This will solve the ''unresolved external'' error
Hey again

Well, Jesse you helped me, and then I also figured out one other thing i did wrong the code was the like this:

#include "ddutil.h"
#include

I did that when I should of included the ddraw.h file first, oh well, thanks Jesse, you helped.



Later


Edited by - JSCFaith on July 14, 2000 8:15:53 PM

Edited by - JSCFaith on July 14, 2000 8:16:47 PM

This topic is closed to new replies.

Advertisement