开发者

VC++, linking error with wxWidgets, x64

开发者 https://www.devze.com 2023-03-05 12:35 出处:网络
I\'m compiling a VC++ 10 application on Windows 7 x64 with wxWidgets 2.8. And this is the errors I have. The code is generated using wxFormBuilder.

I'm compiling a VC++ 10 application on Windows 7 x64 with wxWidgets 2.8. And this is the errors I have. The code is generated using wxFormBuilder.

Update: I try to run it on 32-bit machine as well, still having the same problem.

I have no idea which wxwidgets libraries I'm missing out, or what settings did I do it wrong. Tried both in Debug and Release mode.

I'd really appreciate if someone could point to some hints! Been looking at this problem for a while.


1>WelcomeDlg.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)
1>ConsoleDlg.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)
1>ControlDialog.obj : error LNK2019: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B) referenced in function "public: void __cdecl ControlDialog::loadFile(class std::basic_string,class std::allocator >)" (?loadFile@ControlDialog@@QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)
1>MainFrame.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)
1>MainFrame.obj : error LNK2019: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB) referenced in function "public: __cdecl MainFrame::MainFrame(class wxWindow *,class UIApp *)" (??0MainFrame@@QEAA@PEAVwxWindow@@PEAVUIApp@@@Z)
1>UIApp.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>VISUI.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>WelcomeDlg.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>ConsoleDlg.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>ControlDialog.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>Helper.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxStringBase::npos" (?npos@wxStringBase@@2_KB)
1>MainFrame.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>UIApp.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>VISUI.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>WelcomeDlg.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>ConsoleDlg.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>ControlDialog.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>Helper.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "char const * const wxEmptyString" (?wxEmptyString@@3PEBDEB)
1>ControlDialog.obj : error LNK2001: unresolved external symbol "class wxMBConvUTF8 & wxConvUTF8" (?wxConvUTF8@@3AEAVwxMBConvUTF8@@EA)
1>Helper.obj : error LNK2001: unresolved external symbol "class wxMBConvUTF8 & wxConvUTF8" (?wxConvUTF8@@3AEAVwxMBConvUTF8@@EA)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "protected: static struct wxEventTable const wxGLCanvas::sm_eventTable" (?sm_eventTable@wxGLCanvas@@1UwxEventTable@@B)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "char const * const wxFrameNameStr" (?wxFrameNameStr@@3QBDB)
1>VISUI.obj : error LNK2001: unresolved external symbol "char const * const wxFrameNameStr" (?wxFrameNameStr@@3QBDB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "class wxPalette wxNullPalette" (?wxNullPalette@@3VwxPalette@@A)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "class wxCursor wxNullCursor" (?wxNullCursor@@3VwxCursor@@A)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "int const wxEVT_NULL" (?wxEVT_NULL@@3HB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "int const wxEVT_ERASE_BACKGROUND" (?wxEVT_ERASE_BACKGROUND@@3H开发者_如何学CB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "int const wxEVT_PAINT" (?wxEVT_PAINT@@3HB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "int const wxEVT_SIZE" (?wxEVT_SIZE@@3HB)
1>WxWidgetsWindow.obj : error LNK2001: unresolved external symbol "int const wxEVT_IDLE" (?wxEVT_IDLE@@3HB)

The libraries I'm linking against (64-bit wxwidgets libraries)

wxbase28.lib wxmsw28_core.lib wxmsw28_richtext.lib wxmsw28_html.lib wxmsw28_gl.lib wxmsw28_adv.lib comctl32.lib Rpcrt4.lib

My compiling settings:

  • Treat Wchat_t as built in type: Yes
  • Multi-threaded Debug DLL


I found the solution to my own problem. Just post here in case anyone faces it.

It's not about x64 or x32, neither about wxWidgets. I just need to add these 2 lines in header (before #include <wx/wx.h>)

#define __WXMSW__
#define WXUSINGDLL


How did you build wxWidgets? My understanding is that you will have to change the Visual Studio projects files distributed with wxWidgets, so that it builds in 64-bit mode. Unless you are targeting 32-bit mode. So make sure that you are targeting the same architecture with both your application and wxWidgets (i.e. both should be either 32 or 64 bit).

Also, last I looked, wxWidgets 2.8 doesn't support x64, you will need to upgrade to wxWidgets 2.9 if you want to target x64.

You can also check out the following link: http://wiki.wxwidgets.org/Supporting_x64_and_Win32_within_one_solution


1>WelcomeDlg.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition@@3VwxPoint@@B)

This is an extremely strange external symbol. What is 'class' doing there - it is a C++ keyword. What are all the spaces doing?

My guess is that something horrible happened during compilation. Are you certain you even submitted your source code to a C++ compiler?


Had the same problems on MSVC 2019 as described in the question when try to build from precompiled binaries downloaded from site. When I compiled from source from ...\build\msw\wx_vc12.sln with "Release" option (NOT "Release DLL", but "Release") and get "vc_x64_lib" folder everything works. In my case no needs specify #define __WXMSW__ and #define WXUSINGDLL, just check you build with Multi-threaded DLL (/MD)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号