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

## Recommended Posts

Hi, i am using a small XML library with my game (i gave up on using my friend's code, if you read my other post). I compiled it into a .lib and linked it with my project. But i get link errors:
Generating Code...
SOIL.lib(SOIL.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
IconButton.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall XMLNode::getAttribute(char const *,int *)const " (?getAttribute@XMLNode@@QBEPBDPBDPAH@Z)
Label.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall XMLNode::getAttribute(char const *,int *)const " (?getAttribute@XMLNode@@QBEPBDPBDPAH@Z)
Panel.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall XMLNode::getAttribute(char const *,int *)const "
...


That is a snippet of the link errors, there are more but they are all the same. I tweaked the XML code before i compiled it into the .lib but that shouldn't matter because i made sure i included the modified .h and .lib file in my game project. So i don't see why i am getting these link errors, is it maybe some conflicting settings in Visual Studio? (btw, i am using WinXP, MSVC, and SDL). I tried reading the MSVC help on link error LNK2001 but i don't know where to start, i don't know what could be causing the error. If anyone has the slightest idea on what i have done wrong, or if you would like to see my full code, i would be very grateful. thanks [Edited by - XTAL256 on July 5, 2008 6:21:52 PM]

##### Share on other sites
somewhat unrelated but i added /NODEFAULTLIB:LIBCMT.lib to resolve LNK4098 but it didn't solve my problem. I would post my code but it's a bit messy since i am changing all my code to use the new XML library so i will only post it if anyone would like to see it.

##### Share on other sites
Did you check if you build the xml library with the same runtime library option as your project? (Project Configuration -> C/C++ -> Code Generation ... Multi-threaded Debug (/MTd), ...)

h.

##### Share on other sites
Quote:
 Original post by XTAL256somewhat unrelated but i added /NODEFAULTLIB:LIBCMT.lib to resolve LNK4098 but it didn't solve my problem. I would post my code but it's a bit messy since i am changing all my code to use the new XML library so i will only post it if anyone would like to see it.
What version of visual studio? I haven't seen that error since VC6...

The linker errors you're getting means that the compiler/linker doesn't know where to find the implementation of XMLNode::getAttribute(). Make sure that the library has that function in it, the .lib is linked into the project in your project settings, and the .lib is compiled with the same version of visual studio as your exe.

##### Share on other sites
Quote:
 Original post by Evil SteveWhat version of visual studio? I haven't seen that error since VC6...

Honestly, i have no idea why i get errors like that. I don't know what LIBCMT.lib is, probably some sort of C runtime library. I also need to exclude MSVCRT.lib from linking and i don't know why i have to do that either. But that's not really a worry to me, i just include/exclude whatever libraries are needed for the project.

Quote:
 Original post by Evil SteveThe linker errors you're getting means that the compiler/linker doesn't know where to find the implementation of XMLNode::getAttribute(). Make sure that the library has that function in it, the .lib is linked into the project in your project settings, and the .lib is compiled with the same version of visual studio as your exe.

Yeah, i know all that. That's what i was talking about in my first post. I said "I compiled it into a .lib", so i know that the VS version is the same as my project. "i made sure i included the modified .h and .lib file in my game", so yeah, i did all that. But other than that i don't know what else is wrong.

@hoLogramm: ah, that's another thing i don't know about [embarrass]. I have my game project set as "debug" and use "Multi-threaded Debug DLL (/MDd)". I compiled the XML lib as "release" (since the author says it's a lot faster in release mode) and "Multi-threaded (/MT)". That was already set in the VS project that came with the library code i downloaded. It also has "Function-Level Linking" set (i don't know what that is either). I set the XML project to "Multi-threaded DLL" but it still didn't work. Can i use non-debug runtime with the XML library and use it with my project in "debug" mode?

##### Share on other sites
sorry for double post.. see below

##### Share on other sites
Quote:
 @hoLogramm: ah, that's another thing i don't know about [embarrass]. I have my game project set as "debug" and use "Multi-threaded Debug DLL (/MDd)". I compiled the XML lib as "release" (since the author says it's a lot faster in release mode) and "Multi-threaded (/MT)". That was already set in the VS project that came with the library code i downloaded. It also has "Function-Level Linking" set (i don't know what that is either). I set the XML project to "Multi-threaded DLL" but it still didn't work. Can i use non-debug runtime with the XML library and use it with my project in "debug" mode?

Yes, you can mix debug and release versions. Libraries compiled in release mode only means, that they don't contain any debug symbols.
The problem i see is that you compiled with multi-threaded and multi-threaded dll. Change both to multi-threaded (debug or release) and that should fix your problem.

Quote:
 Honestly, i have no idea why i get errors like that. I don't know what LIBCMT.lib is, probably some sort of C runtime library. I also need to exclude MSVCRT.lib from linking and i don't know why i have to do that either. But that's not really a worry to me, i just include/exclude whatever libraries are needed for the project.

libcmt.lib ... static link library for c++ (release)
libcmtd.lib .. same only for debug
msvcrt.lib ... dynamic link library for c++ (release)
msvcrtd.lib ... same only for debug
libc.lib, libcd.lib ... c libraries

find out more here

Because those are standard libraries which get included automatically, you have to ignore all versions that don't match your build environment, since they define the same function set.

e.g.
I ignore these libraries, when building my project in static debug mode:
libcmt.lib msvcrt.lib msvcrtd.lib libc.lib libcd.lib

and in static release mode:
libcmtd.lib msvcrt.lib msvcrtd.lib lic.lib libcd.lib

h.

##### Share on other sites
Quote:
 Original post by hoLogrammThe problem i see is that you compiled with multi-threaded and multi-threaded dll. Change both to multi-threaded (debug or release) and that should fix your problem.

Is there any reason why i must change them to multi-threaded and not multi-threaded dll? Because after i last posted, i changed the XML lib to match my project's settings (multi-threaded debug DLL) but i still got the link errors. I will try changing both to multi-threaded.

##### Share on other sites
Ok, i changed my game project and the XML lib to multi-threaded (debug and release respectively) and it still doesn't work. I will post the project settings in case there is anther reason why i might be getting this error:

Ballistic (my game) project:
C++ compiler:/Od /I "C:\...\Ballistic\src\\" /D "WIN32" /D "_DEBUG" /FD /EHsc /MDd /fp:fast/Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Zi /TP /errorReport:promptLinker:/OUT:"..\\Ballistic.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\Ballistic.exe.intermediate.manifest" /NODEFAULTLIB:"MSVCRT"/NODEFAULTLIB:"LIBCMT" /DEBUG /ASSEMBLYDEBUG /PDB:"c:\...\Ballistic\src\Debug\Ballistic.pdb" /SUBSYSTEM:WINDOWS /ENTRY:"mainCRTStartup" /MACHINE:X86 /ERRORREPORT:PROMPT "C:\...\Ballistic\src\soil\SOIL.lib" "C:\...\Ballistic\src\utils\dirent.lib" "C:\...\Ballistic\src\utils\xmlParser.lib" user32.lib ole32.lib gdi32.lib OpenGL32.lib GLu32.lib GLaux.lib SDL.lib SDLmain.lib SDL_mixer.lib  kernel32.lib

XML library project:
C++ compiler:/O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0600" /D "_UNICODE" /D "UNICODE" /GF /FD /EHsc /MD /Gy /Fp".\Release/xmlParser.pch" /Fo".\Release/" /Fd".\Release/" /W3 /nologo /c /TP /errorReport:promptLibrarian:/OUT:".\Release\xmlParser.lib" /NOLOGO

NOTE: I have abbreviated the project path with ... and I copy the .lib file from ".\Release" to the path shown above.

##### Share on other sites
This error isn't related to CRT library. (Link warnings are, though) I think the problem can be completely solved if you can post the whole source. (It's silly, I know) What I could imagine is:

- Are you sure the .cpp file(s) which contain the implementation of XMLNode class are included in the XML project?
- Isn't it possible the implementations are excluded via preprocess directives, such as #ifdef-#endif?

And if you can post the xmlParser.lib file, I can tell more informations.

Regards

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
15

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009195
• ### Who's Online (See full list)

There are no registered users currently online

×