Windows下wxWidgets编译错误的解决方法
错误提示:
d:\develop\audacity\wxwidgets-3.1.1\include\wx\platform.h(148): fatal error C1083: 无法打开包括文件: “wx/setup.h”: No such file or directory
解决方法:
1.到D:\develop\audacity\wxWidgets-3.1.1\include\wx\目录下, 找到platform.h文件,用notepad++打开
2.找到 #include "wx/setup.h" 一行
/* Include wx/setup.h for the Unix platform defines generated by configure and the library compilation options Note that it must be included before defining hardware symbols below as they could be already defined by configure but it must be included after defining the compiler macros above as msvc/wx/setup.h relies on them under Windows. */ #include "wx/setup.h"
3.将 "wx/setup.h" 改为 "wx/msw/setup.h", 然后保存修改后的platform.h文件即可,之后你再去编译工程,就不会出现这个错误了
原来官方给的下载包里的wx.chm帮助文件有这个问题的解决办法,意思是说,wx/...目录里根本没有setup.h文件, 首先要在platform.h文件里进行配置, 格式大致是 #include "wx/XXX/setup.h", 而这里的XXX是根据你所用的操作系统的不同而改变的,例如WINDOW下就改成"wx/msw/setup.h", 而MacOS就改成"wx/mac/setup.h"
错误提示:
hello.o:main.cpp:(.text+0x53): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)‘
hello.o:main.cpp:(.text+0x89): undefined reference to `wxAppConsoleBase::CheckBuildOptions(char const*, char const*)‘
hello.o:main.cpp:(.text+0x416): undefined reference to `wxMenuBar::wxMenuBar()‘
hello.o:main.cpp:(.text+0x4dd): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)‘
hello.o:main.cpp:(.text+0x51f): undefined reference to `wxFrameBase::CreateStatusBar(int, long, int, wxString const&)‘
hello.o:main.cpp:(.text+0x560): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)‘
hello.o:main.cpp:(.text+0x69b): undefined reference to `wxFrame::~wxFrame()‘
办法: