Weird problem

Started by
4 comments, last by Rhalin 16 years, 4 months ago
I just recently got Visual C++ Express 2008 and the Dark GDK and everytime I try to include any standard libraries using the Dark GDK wizard I get the following linker errors: Compiling... Player.cpp Main.cpp Generating Code... Linking... LINK : Debug\Yahtzee.exe not found or not built by the last incremental link; performing full link libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z) Debug\Yahtzee.exe : fatal error LNK1120: 2 unresolved externals what am I missing?
Advertisement
Does the DarkGDK library have a debug version? And if so, are you linking to that? Both your code and the DarkGDK libs have to link to the same version of the C Runtime Library. It seems as though one is the debug version "libcpmtd.lib" and the other is using the release version "libcmt.lib".
Well I looked farther and it seems to be ignoring the libcptmtd.lib and I guess one of those are what has all the standard headers I am trying to include but I see why because when I took it off ignore it said a lot of stuff was already defined. Guess I just gotta rely on other sources of stuff and use character arrays instead of strings.
Quote:Original post by Nabren
Well I looked farther and it seems to be ignoring the libcptmtd.lib and I guess one of those are what has all the standard headers I am trying to include but I see why because when I took it off ignore it said a lot of stuff was already defined. Guess I just gotta rely on other sources of stuff and use character arrays instead of strings.


As I mentioned on another thread with a very similar (possibly the same problem) using the nodefaultlib flag as the compiler suggests is -not- the right thing to do. The message should probably read something like "There are conflicting or different versions of the C runtime library used in the project and a library that the project is linking against", but that would just make sense, so it doesn't.

I'd suggest removing Nodefaultlib if you added it on and follow MJP's advice. You can read the other thread I mentioned here where someone had a nearly identical problem. Doing some googling for "warning LNK4098" or "LNK2019" should turn up quite a few results too, as these are pretty common problems.
Ya, that was exactly it - thank you. Upon setting it to release it fixed the errors however how would I set it to use the debug versions so I could have the option of debugging while I am working on it? Can't seem to find where the debug linker to the libraries is wrong.
Quote:Original post by Nabren
Ya, that was exactly it - thank you. Upon setting it to release it fixed the errors however how would I set it to use the debug versions so I could have the option of debugging while I am working on it? Can't seem to find where the debug linker to the libraries is wrong.


What you'll need to do is find the debug version of the library you're linking against. Usually it's the same as the release build, but with a "d" at the end - for instance, if the release library is darkgdk.lib, there should be a darkgdkd.lib as well.

Then you specify this library in the properties of the project.
Project menu -> <projectname> Properties
Linked libraries are found under Configuration Properties -> Linker -> Input then Additional Dependancies.

Here's where things change. You specify the Configuration via a drop-down at the top of the window. Select Debug and put the darkgdkd.lib (or whatever it is called) in additional dependencies. Then select Release and make sure the additional dependencies there do -not- use the debug version.

You'll have to look around darkgdk to see if they offer a debug version, and also to find out where they put it to add the directories if needed. If they don't, then it might be quite a bit more difficult to link against in debug mode.

-Rhalin

This topic is closed to new replies.

Advertisement