【发布时间】:2021-07-16 05:48:48
【问题描述】:
我已经可以使用x86_64-w64-mingw32-g++ 交叉编译一些简单的应用程序。但是,我不知道如何为我的项目查找库(在我的情况下,我需要使用 SDL2 和 SDL2_image)。我已经知道如何安装这些库(sudo apt install libsdl2-dev libsdl2-image-dev),但apt search 没有显示任何x86_64-w640mingw32-g++ 的库。
以下是我查看过的链接:
https://arrayfire.com/cross-compile-to-windows-from-linux/
https://stackoverflow.com/questions/2033997/how-to-compile-for-windows-on-linux-with-gcc-g
有没有办法使用预编译的库,或者我需要在我的项目中添加源代码?
更新:我按照 Laurent Jospin 的建议,可以编译一个适用于 Windows 的“Hello World”程序(我将它发送给朋友测试)。但是,我无法编译使用 SDL 的程序。
终端输出:
$ /opt/mxe/usr/bin/x86_64-w64-mingw32.shared-g++ -O3 main.o Game.o TextureManager2D.o Map.o Entity.o Player.o -mwindows -lSDL2 -lSDL2_image -o ../../../endeavour-client.exe
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/5.5.0/../../../../x86_64-w64-mingw32.shared/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function `main':
/opt/mxe/tmp-gcc-x86_64-w64-mingw32.shared/gcc-5.5.0.build_.crt/../gcc-5.5.0.build_/mingw-w64-v8.0.0/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2: error: ld returned 1 exit status
$
将-mwindows 更改为-municode、-d UNICODE、-Wl,-subsystem,windows 或将其全部删除都不起作用。
【问题讨论】:
-
买个便宜的带windows的硬盘会更快更简单。
-
会的,但我没有钱买。
-
然后忘掉 Windows,继续在 Linux 上编码。顺便说一句,我从 1974 年开始编码,从未使用过 Windows。如果你买不起(我也买不起),请不要使用它。如果您的老板或客户需要 Windows,他必须向您支付 Windows 许可证。在大多数国家/地区使用某些未付费的 Windows 是非法的(因此您可能会遇到法律问题或罚款)。
-
顺便说一句,您可能会对RefPerSys 项目(Linux 上的符号 AI,免费软件)感兴趣。然后通过电子邮件与我联系
basile@starynkevitch.net -
请你的朋友用你的 C++ 代码在他/她自己的 Windows 计算机上编译 Windows 变种,然后给他发一些在 Linux 上运行的 C++ 代码
标签: c++ linux windows mingw cross-compiling