使用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的庫編譯失敗,不過這么依賴語言外的額外實現也不見得是件好事吧。
|
新聞熱點
疑難解答
圖片精選