Code::Blocks/wxWidgets 交叉编译 Windows 失败

问题描述 投票:0回答:1

我正在尝试在 Linux 中设置 Code::Blocks 以针对 Windows 进行交叉编译。我可以在编译器之间切换,但是当我尝试编译一个(新的空的)wxWidgets 项目时。 Linux 编译器成功,我可以在 Linux 中运行二进制文件。 MingW 编译器会产生很多我无法解释的错误。工具链设置中列出的所有 MingW 工具都存在。没有关于丢失 wx 包含文件的消息。
任何人都可以解释导致这些消息的原因吗?

构建日志以这些行开头:

-------------- Build: Debug in wxTest (compiler: MingW GNU GCC cross compiler for Windows)---------------

i686-w64-mingw32-g++ -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -I/usr/i686-w64-mingw32/include/ -c /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.cpp -o obj/Debug/wxTestApp.o
i686-w64-mingw32-g++ -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -I/usr/i686-w64-mingw32/include/ -c /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.cpp -o obj/Debug/wxTestMain.o
i686-w64-mingw32-g++ -L/usr/i686-w64-mingw32/lib/ -o bin/Debug/wxTest obj/Debug/wxTestApp.o obj/Debug/wxTestMain.o  -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_qa-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0   
In file included from /usr/include/wx-3.0/wx/chkconf.h:1222,
                 from /usr/include/wx-3.0/wx/platform.h:596,
                 from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/event.h:14,
                 from /usr/include/wx-3.0/wx/app.h:19,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.h:13,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.cpp:10:
/usr/i686-w64-mingw32/include/wx-3.0/wx/msw/chkconf.h:394:13: error: #error "wxUSE_DATAOBJ requires wxUSE_OLE"
  394 | #           error "wxUSE_DATAOBJ requires wxUSE_OLE"
      |             ^~~~~
/usr/i686-w64-mingw32/include/wx-3.0/wx/msw/chkconf.h:414:13: error: #error "wxMediaCtl requires wxActiveXContainer"
  414 | #           error "wxMediaCtl requires wxActiveXContainer"
      |             ^~~~~
In file included from /usr/include/wx-3.0/wx/platform.h:596,
                 from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/event.h:14,
                 from /usr/include/wx-3.0/wx/app.h:19,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.h:13,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.cpp:10:
/usr/include/wx-3.0/wx/chkconf.h:1630:13: error: #error "wxRearrangeCtrl requires wxCheckListBox"
 1630 | #           error "wxRearrangeCtrl requires wxCheckListBox"
      |             ^~~~~
In file included from /usr/include/wx-3.0/wx/chkconf.h:1222,
                 from /usr/include/wx-3.0/wx/platform.h:596,
                 from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/event.h:14,
                 from /usr/include/wx-3.0/wx/window.h:18,
                 from /usr/include/wx-3.0/wx/nonownedwnd.h:14,
                 from /usr/include/wx-3.0/wx/toplevel.h:20,
                 from /usr/include/wx-3.0/wx/frame.h:18,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.h:14,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.cpp:10:
/usr/i686-w64-mingw32/include/wx-3.0/wx/msw/chkconf.h:394:13: error: #error "wxUSE_DATAOBJ requires wxUSE_OLE"
  394 | #           error "wxUSE_DATAOBJ requires wxUSE_OLE"
      |             ^~~~~
/usr/i686-w64-mingw32/include/wx-3.0/wx/msw/chkconf.h:414:13: error: #error "wxMediaCtl requires wxActiveXContainer"
  414 | #           error "wxMediaCtl requires wxActiveXContainer"
      |             ^~~~~
In file included from /usr/include/wx-3.0/wx/platform.h:596,
                 from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/event.h:14,
                 from /usr/include/wx-3.0/wx/window.h:18,
                 from /usr/include/wx-3.0/wx/nonownedwnd.h:14,
                 from /usr/include/wx-3.0/wx/toplevel.h:20,
                 from /usr/include/wx-3.0/wx/frame.h:18,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.h:14,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.cpp:10:
/usr/include/wx-3.0/wx/chkconf.h:1630:13: error: #error "wxRearrangeCtrl requires wxCheckListBox"
 1630 | #           error "wxRearrangeCtrl requires wxCheckListBox"
      |             ^~~~~
In file included from /usr/include/wx-3.0/wx/memory.h:15,
                 from /usr/include/wx-3.0/wx/object.h:19,
                 from /usr/include/wx-3.0/wx/event.h:16,
                 from /usr/include/wx-3.0/wx/window.h:18,
                 from /usr/include/wx-3.0/wx/nonownedwnd.h:14,
                 from /usr/include/wx-3.0/wx/toplevel.h:20,
                 from /usr/include/wx-3.0/wx/frame.h:18,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.h:14,
                 from /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.cpp:10:
/usr/include/wx-3.0/wx/string.h:211:15: error: ‘wxUniChar wxCStrData::operator[](unsigned int) const’ cannot be overloaded with ‘wxUniChar wxCStrData::operator[](size_t) const’
  211 |     wxUniChar operator[](unsigned int n) const { return operator[](size_t(n)); }
      |               ^~~~~~~~
/usr/include/wx-3.0/wx/string.h:207:22: note: previous declaration ‘wxUniChar wxCStrData::operator[](size_t) const’
  207 |     inline wxUniChar operator[](size_t n) const;
      |                      ^~~~~~~~
/usr/include/wx-3.0/wx/string.h:1551:15: error: ‘wxUniChar wxString::operator[](unsigned int) const’ cannot be overloaded with ‘wxUniChar wxString::operator[](size_t) const’
 1551 |     wxUniChar operator[](unsigned int n) const
      |               ^~~~~~~~
/usr/include/wx-3.0/wx/string.h:1548:15: note: previous declaration ‘wxUniChar wxString::operator[](size_t) const’
 1548 |     wxUniChar operator[](size_t n) const

如果这是相关的,我用这些行编译了 wxWidgets:

./configure prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 --enable-unicode --build=`./config.guess` --disable-shared

make

make install

./configure 退出:为`i686-w64-mingw32'配置wxWidgets 3.0.5

但是在我运行 make 之前,config.log 包含这些错误

$ cat config.log|grep -i "error:"
i686-w64-mingw32-gcc: error: unrecognized command line option '-V'
i686-w64-mingw32-gcc: fatal error: no input files
i686-w64-mingw32-gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
i686-w64-mingw32-gcc: fatal error: no input files
conftest.c:15:17: error: unknown type name 'choke'
conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory
conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory
conftest.c:9:10: fatal error: sgtty.h: No such file or directory
conftest.c:9:10: fatal error: termio.h: No such file or directory
i686-w64-mingw32-g++: error: unrecognized command line option '-V'
i686-w64-mingw32-g++: fatal error: no input files
i686-w64-mingw32-g++: error: unrecognized command line option '-qversion'; did you mean '--version'?
i686-w64-mingw32-g++: fatal error: no input files
conftest.cpp:15:17: error: 'choke' was not declared in this scope
conftest.cpp:15:17: error: 'choke' was not declared in this scope
conftest.c:57:10: fatal error: langinfo.h: No such file or directory
conftest.c:60:12: error: size of array 'test_array' is negative
c++ mingw cross-compiling codeblocks wxwidgets
1个回答
0
投票

我为小部件尝试了不同的编译选项,但并没有导致上述问题。今天发现 wx-config 的文件权限执行位不见了:

/usr/i686-w64-mingw32/bin/wx-config: Permission denied

现在我已经改变了它,我在构建日志中收到了很多不同的消息:

i686-w64-mingw32-g++ -Wall -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -g -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -I/usr/i686-w64-mingw32/include/ -c /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestApp.cpp -o obj/Debug/wxTestApp.o
i686-w64-mingw32-g++ -Wall -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -g -I/usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/i686-w64-mingw32/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads -I/usr/i686-w64-mingw32/include/ -c /home/data/VBOX/VBOX_DATA/CodeBlocks/wxTest/wxTestMain.cpp -o obj/Debug/wxTestMain.o
i686-w64-mingw32-g++ -L/usr/i686-w64-mingw32/lib/ -o bin/Debug/wxTest obj/Debug/wxTestApp.o obj/Debug/wxTestMain.o  -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_qa-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0   
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_gtk3u_xrc-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_gtk3u_html-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_gtk3u_qa-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_gtk3u_adv-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_gtk3u_core-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_baseu_xml-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_baseu_net-3.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lwx_baseu-3.0
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
9 error(s), 0 warning(s) (0 minute(s), 1 second(s))

我还解决了最后一点,编译器试图链接 linux 库。在“全局编译器设置”->“链接器设置”->“其他链接器选项”->“`wx-config --libs`”中更改后 至:“`/usr/i686-w64-mingw32/bin/wx-config --libs`”那些消息消失了。 此外,“编译器设置”->“`/usr/i686-w64-mingw32/bin/wx-config --cflags`”需要 Windows 版本的 wx-config 的完整路径。

我上次配置wxWidgets:

./configure --prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 --enable-unicode --build=`./config.guess` --disable-shared --with-msw

现在我的项目为 Windows 交叉编译

© www.soinside.com 2019 - 2024. All rights reserved.