How to compile for Windows on Linux with gcc/g++?(如何使用 gcc/g++ 在 Linux 上为 Windows 编译?)
问题描述
我在 Linux 上使用 freeglut 在 C++ (g++) 中编写了一些效果,并使用
I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
所以我想知道是否有可能让 g++ 生成包含所需一切的静态编译 Windows 可执行文件?
So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?
我没有 Windows,所以如果我能在 Linux 上做到这一点,那就太酷了 :)
I don't have Windows, so it would be really cool, if I could do that on Linux :)
推荐答案
mingw32 作为 Linux 的一个包存在.您可以使用它交叉编译和链接 Windows 应用程序.在 Code::Blocks 论坛上有一个教程.例如,请注意命令更改为 x86_64-w64-mingw32-gcc-win32.
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32, for example.
例如,Ubuntu 的存储库中有 MinGW:
Ubuntu, for example, has MinGW in its repositories:
$ 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
[...]
这篇关于如何使用 gcc/g++ 在 Linux 上为 Windows 编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 gcc/g++ 在 Linux 上为 Windows 编译?
基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
