问题
I am trying to compile my project with an open source library GDCM on Visual C++ 2010 on Windows 7 64 bits. I have included required .lib files (gdcmDSED.lib and gdcmMSFF.lib) in my project, however, the compiler complains back more than 100 unresolved external errors. But I see some patterns in the errors. Here:
1>gdcmDSED.lib(gdcmSequenceOfItems.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
...
...
1>gdcmMSFF.lib(gdcmCurve.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
1>gdcmDSED.lib(gdcmCSAHeader.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
These are 1 warning and 2 errors from total 100. This is for better clarification. I can see that the compiler complains all these warnings and errors, either about "locally defined symbol" and "unresolved external symbol". Moreover, it seems that the error originates from the .lib files themselves (not from [my project's name].obj), as you can see above.
I have tried include all the .lib files from the library, but that does not seem to solve it. Worse, the compiler outputs more of the same warnings and errors.
Am I forgetting something here? What must I do in order to solve this problem?
回答1:
Found this on the internet : The problems disappear when creating the gdcm DLL with the BUILD_SHARED_LIBS ON.
Does this ring a bell ?
see: http://www.creatis.insa-lyon.fr/pipermail/dcmlib/2007-April.txt
回答2:
That basic_string needs #include <string>,
have you tried that?
来源:https://stackoverflow.com/questions/4757962/solving-locally-defined-symbol-and-unresolved-external-symbol-that-originate