Page 1 of 1

Unresolved External Symbol

Posted: Mon Sep 12, 2011 12:06 pm
by rtr1811
Hi!
I got the following linker error while building minimal application in the samples folder.

unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(struct std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::_Has_debug_it)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@U_Has_debug_it@01@@Z) referenced in function "public: __thiscall wxString::wxString(void)" (??0wxString@@QAE@XZ)

My library files are:

Code: Select all

wxmsw29u_core.lib
wxbase29u.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxregexud.lib
wxexpatd.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
I'm using wxWidgets version 2.9.1

How to resolve this error?

Re: Unresolved External Symbol

Posted: Mon Sep 12, 2011 1:57 pm
by briceandre
which compiler ?
If msvc, check that you use the same runtime for each compiled object, as well as for the build of wxWidgets, as well as for the link of the application (MD, MDd, MT or MTd)

Re: Unresolved External Symbol

Posted: Mon Sep 12, 2011 3:02 pm
by rtr1811
briceandre wrote: which compiler ?
MSVC. I checked and changed the project settings as you said. But I got the following errors while running my project in
Debug mode:

LINK : warning LNK4098: defaultlib 'LIBCMT' 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(xmbtowc.obj) : error LNK2001: unresolved external symbol __malloc_dbg
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)
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __free_dbg
libcpmtd.lib(stdthrow.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z)
libcpmtd.lib(cerr.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
libcpmtd.lib(_tolower.obj) : error LNK2019: unresolved external symbol __calloc_dbg referenced in function __Getctype
D:\WxTest\Debug\WxTest.exe : fatal error LNK1120: 4 unresolved externals

But while running in release mode, I got plenty of errors(more than four thousand). I give some of those here:

libcpmtd.lib(cerr.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(base64.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(textfile.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libcpmtd.lib(string.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libcpmtd.lib(locale0.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(process.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(fileconf.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(mimetype.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(ipcbase.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(longlong.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(mimecmn.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(fileback.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
wxbase29u.lib(dde.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4

What else to do?

Re: Unresolved External Symbol

Posted: Mon Sep 12, 2011 6:19 pm
by Lprd2007
Check if both your application and wxWidgets are compiled against the same Runtime Library. You can see and change this setting in the project's configuration dialog and then going to C/C++ > Code Generation > Runtime Library.
Second, make sure that they are also using the same Character Set (project configuration > Character Set). My VC2008 sets Unicode by default, which is incompatible with older wxWidgets builds (<= 2.8.x). Setting "Multi-byte" or "Not Set" should be fine.
Check this settings for every static library your project is using.