Search code examples
c++visual-studiovisual-studio-2015wxwidgets

wxWidgets Visual Studio 2015 Link Errors


I am trying to run the minimal wxWidgets sample using Visual Studio Community 2015 under Windows 10. wxWidgets version is 3.1.0.

I have compiled wxWidgets using the following command:

nmake -f makefile.vc SHARED=1 UNICODE=1 MONOLITHIC=1 BUILD=release

The compilation of wxWidgets was successful with above-mentioned command.

The minimal wxWidgets example compiles well but I get the following link errors in the release version (havent tried debug yet):

error LNK2001: unresolved external symbol "void (__cdecl* wxTheAssertHandler)(class wxString const &,int,class wxString const &,class wxString const &,class wxString const &)" (?wxTheAssertHandler@@3P6AXABVwxString@@H000@ZA)
1>Source.obj : error LNK2001: unresolved external symbol "class wxEventTypeTag<class wxCommandEvent> const wxEVT_MENU" (?wxEVT_MENU@@3V?$wxEventTypeTag@VwxCommandEvent@@@@B)
1>Source.obj : error LNK2001: unresolved external symbol "protected: static class wxAppConsole * (__cdecl* wxAppConsoleBase::ms_appInitFn)(void)" (?ms_appInitFn@wxAppConsoleBase@@1P6APAVwxAppConsole@@XZA)
1>Source.obj : error LNK2001: unresolved external symbol "char const * const wxFrameNameStr" (?wxFrameNameStr@@3QBDB)
1>Source.obj : error LNK2001: unresolved external symbol "protected: static class wxAppConsole * wxAppConsoleBase::ms_appInstance" (?ms_appInstance@wxAppConsoleBase@@1PAVwxAppConsole@@A)
1>Source.obj : error LNK2001: unresolved external symbol "class wxMBConv * wxConvLibcPtr" (?wxConvLibcPtr@@3PAVwxMBConv@@A)
1>Source.obj : error LNK2001: unresolved external symbol "char const * const wxLOG_COMPONENT" (?wxLOG_COMPONENT@@3PBDB)
1>Source.obj : error LNK2001: unresolved external symbol "public: static unsigned int const wxString::npos" (?npos@wxString@@2IB)
1>Source.obj : error LNK2001: unresolved external symbol "class wxSize const wxDefaultSize" (?wxDefaultSize@@3VwxSize@@B)
1>Source.obj : error LNK2001: unresolved external symbol "bool wxTrapInAssert" (?wxTrapInAssert@@3_NA)
1>Source.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxEmptyString" (?wxEmptyString@@3PB_WB)
1>Source.obj : error LNK2001: unresolved external symbol "private: static bool wxLog::ms_doLog" (?ms_doLog@wxLog@@0_NA)
1>Source.obj : error LNK2001: unresolved external symbol "char const * const wxStatusLineNameStr" (?wxStatusLineNameStr@@3QBDB)
1>Source.obj : error LNK2001: unresolved external symbol "private: static unsigned long wxThread::ms_idMainThread" (?ms_idMainThread@wxThread@@0KA)
1>Source.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)

I have the following Preprocessor definitions:WIN32;_UNICODE;__WXMSW__;UNICODE

The whole linker flags: /OUT:"C:\Users\gb\documents\visual studio 2015\Projects\wxWidgetsDeneme\Release\wxWidgetsDeneme.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"C:\Users\gb\documents\visual studio 2015\Projects\wxWidgetsDeneme\Release\wxWidgetsDeneme.pdb" /DYNAMICBASE "wxmsw31u.lib" "wxmsw31u_gl.lib" "wxexpat.lib" "wxjpeg.lib" "wxpng.lib" "wxscintilla.lib" "wxtiff.lib" "wxzlib.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"C:\Users\gb\documents\visual studio 2015\Projects\wxWidgetsDeneme\Release\wxWidgetsDeneme.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\wxWidgetsDeneme.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Users\gb\Downloads\wxWidgets-3.1.0\lib\vc_dll" /TLBID:1

Any ideas will be appreciated.


Solution

  • Would not think it would have been this simple: just a preprocessor definition was missing: WXUSINGDLL

    In the documentation it mentions: WXUSINGDLL:If you're compiling using DLLs instead of a static build and since I am using nmake -f makefile.vc SHARED=1 ....

    I am just curious now: Why wxWidgets runs without any problem using gcc even if WXUSINGDLL was missing from the preprocessor definition.