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

pb3s4cty  于 2023-04-08  发布在  Windows
关注(0)|答案(1)|浏览(137)

我试图在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 exits with:已为`i686-w 64-mingw 32 '配置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
gstyhher

gstyhher1#

我尝试了不同的编译选项,但没有导致上述问题。今天我注意到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-w 64-mingw 32/bin/wx-config --libs”这些消息都消失了。此外,“编译器设置”-〉“/usr/i686-w 64-mingw 32/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

相关问题