手机
当前位置:查字典教程网 >编程开发 >C语言 >Mingw64编译wxWidgets 3.0.2常见错误分析
Mingw64编译wxWidgets 3.0.2常见错误分析
摘要:使用Mingw64编译wxWidgets3.0.2,首先得下载wxMSW-Setup-3.0.2.exe(https://sourcefor...

使用Mingw64编译wxWidgets3.0.2,首先得下载wxMSW-Setup-3.0.2.exe(https://sourceforge.net/projects/wxwindows/files/3.0.2/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中找到了答案,里面有这么一句话:

C++11 note: If you want to compile wxWidgets in C++11 mode, you currently have

to use -std=gnu++11 switch as -std=c++11 disables some extensions

that wxWidgets relies on. I.e. please use CXXFLAGS="-std=gnu++11".

说的很清楚,不能用”std=c++11"进行编译,这会导致一些wxWidgets依赖的extensions(扩展名?)被屏蔽的问题。然后用以下命令重新编译,就成功了。

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

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

后记

上面说到关于extensions,这里的意思应该是扩展,即gnu的g++(gcc)提供给c/c++代码除c++标准以外的支持。如果这些支持没有被启用,自然会导致上面像wxWidgets的库编译失败,不过这么依赖语言外的额外实现也不见得是件好事吧。

【Mingw64编译wxWidgets 3.0.2常见错误分析】相关文章:

解析C语言中空指针、空指针常量、NULL & 0的详解

C 语言基础教程(我的C之旅开始了)[八]

深入探讨POJ 2312 Battle City 优先队列+BFS

快速模式匹配算法(KMP)的深入理解

C++中用指向数组的指针作函数参数

浅析string类字符串和C风格字符串之间的区别

c语言内存泄露示例解析

浅谈C#互操作的内存溢出问题

深入理解C语言中编译相关的常见错误

基于C++中常见内存错误的总结

精品推荐
分类导航