gpt4 book ai didi

c++ - 如何使用 gcc/g++ 在 Linux 上为 Windows 编译?

转载 作者:IT老高 更新时间:2023-10-28 11:57:02 27 4
gpt4 key购买 nike

我在 Linux 上使用 freeglut 用 C++ (g++) 编写了一些效果,我用它们编译了

g++ -Wall -lglut part8.cpp -o part8

所以我想知道是否可以让 g++ 生成包含所需所有内容的静态编译 Windows 可执行文件?

我没有 Windows,所以如果我能在 Linux 上做到这一点,那就太棒了:)

最佳答案

mingw32 作为 Linux 软件包存在。您可以使用它交叉编译和链接 Windows 应用程序。有教程here at the Code::Blocks forum .请注意,例如,命令更改为 x86_64-w64-mingw32-gcc-win32

例如,Ubuntu 的存储库中有 MinGW:

$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]

关于c++ - 如何使用 gcc/g++ 在 Linux 上为 Windows 编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2033997/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com