Mingw64编译wxWidgets 3.0.2常见错误分析
2019/7/10 22:53:24
本文主要是介绍Mingw64编译wxWidgets 3.0.2常见错误分析,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
使用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.2\build\msw
make -f makefile.gcc SHARED=1 UNICODE=1
然而编译到一半,从C代码变为C++代码时,就会产生如下错误(有许多类似错误,只选取一处):
In file included from e:\mingwd\mingw\include\c++\5.2.0\type_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:\mingwd\mingw\include\c++\5.2.0\bits\c++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.2\lib\gcc_lib64/libwxmsw30ud.a(monolib_filename.o): In function `wxChmod(wxString const&, unsigned short)':
E:\wxWidgets-3.0.2\build\msw/../../include/wx/filefn.h:513: undefined reference to `wxMSLU__wchmod(wchar_t const*, int)'
E:\wxWidgets-3.0.2\lib\gcc_lib64/libwxmsw30ud.a(monolib_filename.o): In function `wxOpen(wxString const&, int, unsigned short)':
E:\wxWidgets-3.0.2\build\msw/../../include/wx/filefn.h:515: undefined reference to `wxMSLU__wopen(wchar_t const*, int, int)'
E:\wxWidgets-3.0.2\lib\gcc_lib64/libwxmsw30ud.a(monolib_file.o): In function `wxRemove(wxString const&)':
E:\wxWidgets-3.0.2\build\msw/../../include/wx/wxcrt.h:758: undefined reference to `wxMSLU__wremove(wchar_t const*)'
E:\wxWidgets-3.0.2\lib\gcc_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常见错误分析的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-27Excel中实现拖动排序的简单教程
- 2024-11-27Rocket消息队列资料:新手入门指南
- 2024-11-27rocket消息队资料详解与入门指南
- 2024-11-27RocketMQ底层原理资料详解入门教程
- 2024-11-27RocketMQ项目开发资料:新手入门教程
- 2024-11-27RocketMQ项目开发资料详解
- 2024-11-27RocketMQ消息中间件资料入门教程
- 2024-11-27初学者指南:深入了解RocketMQ源码资料
- 2024-11-27Rocket消息队列学习入门指南
- 2024-11-26Rocket消息中间件教程:新手入门详解