Mingw64编译wxWidgets 3.0.2常见错误分析

2020-01-06 16:07:22王旭

使用Mingw64编译wxWidgets3.0.2,首先得下载wxMSW-Setup-3.0.2.exe(https://www.easck.com/wxMSW-Setup-3.0.2.exe,然后按照如下步骤编译(假设要编译一个Unicode共享库版的wxWidgets):

cd X:wxWidgets-3.0.2buildmsw

    make -f makefile.gcc SHARED=1 UNICODE=1

  然而编译到一半,从C代码变为C++代码时,就会产生如下错误(有许多类似错误,只选取一处):

In file included from e:mingwdmingwincludec++5.2.0type_traits:35:0,
                   from ....include/wx/strvararg.h:25,
                   from ....include/wx/string.h:46,
                   from ....include/wx/any.h:19,
                   from ../../src/common/any.cpp:18:
e:mingwdmingwincludec++5.2.0bitsc++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

  既然只是c++11支持没有打开的问题,只要改一下CXXFLAGS即可,于是乎,按如下命令重新编译。

    make -f makefile.gcc CXXFLAGS="-std=c++11" SHARED=1 UNICODE=1 clean

    make -f makefile.gcc CXXFLAGS="-std=c++11" SHARED=1 UNICODE=1

  这次编译完了所有中间件,但是到链接时候又出了问题:

    E:wxWidgets-3.0.2libgcc_lib64/libwxmsw30ud.a(monolib_filename.o): In function `wxChmod(wxString const&, unsigned short)':
    E:wxWidgets-3.0.2buildmsw/../../include/wx/filefn.h:513: undefined reference to `wxMSLU__wchmod(wchar_t const*, int)'
    E:wxWidgets-3.0.2libgcc_lib64/libwxmsw30ud.a(monolib_filename.o): In function `wxOpen(wxString const&, int, unsigned short)':
    E:wxWidgets-3.0.2buildmsw/../../include/wx/filefn.h:515: undefined reference to `wxMSLU__wopen(wchar_t const*, int, int)'
    E:wxWidgets-3.0.2libgcc_lib64/libwxmsw30ud.a(monolib_file.o): In function `wxRemove(wxString const&)':
    E:wxWidgets-3.0.2buildmsw/../../include/wx/wxcrt.h:758: undefined reference to `wxMSLU__wremove(wchar_t const*)'
    E:wxWidgets-3.0.2libgcc_lib64/libwxmsw30ud.a(monolib_file.o): In function `wxAccess(wxString const&, unsigned short)':
......

  这实在是令我百思不得其解了,翻遍了docs文件夹的每个角落,终于在install.txt中找到了答案,里面有这么一句话: