将C ++应用程序从Linux交叉编译为Windows的手册? [英] Manual for cross-compiling a C++ application from Linux to Windows?
问题描述
有没有将Linux从C ++应用程序交叉编译为Windows的手册?
Is there a manual for cross-compiling a C++ application from Linux to Windows?
只是这样。我想要一些信息(链接,参考,例子...)来指导我这样做。
Just that. I would like some information (links, reference, examples...) to guide me to do that.
我甚至不知道是否可能。
I don't even know if it's possible.
我的目标是在Linux中编译一个程序,并得到一个可以在Windows下运行的.exe文件。
My objective is to compile a program in Linux and get a .exe file that I can run under Windows.
推荐答案
基本不难过:
sudo apt-get install mingw32
cat > main.c <<EOF
int main()
{
printf("Hello, World!");
}
EOF
i586-mingw32msvc-cc main.c -o hello.exe
用 yum
替换 apt-get
,或者您的Linux发行版使用。这将为Windows生成一个 hello.exe c>。
Replace apt-get
with yum
, or whatever your Linux distro uses. That will generate a hello.exe
for Windows.
一旦你得到了你的头,你可以使用< a href =http://sources.redhat.com/autobook/autobook/autobook_268.html#SEC268> autotools ,并设置 CC = i586-mingw32msvc-cc
Once you get your head around that, you could use autotools, and set CC=i586-mingw32msvc-cc
CC=i586-mingw32msvc-cc ./configure && make
或使用 CMake和一个工具链文件来管理构建。更困难的是添加本机交叉库。通常它们存储在 / usr / cross / i586-mingw32msvc / {include,lib}
中,您需要在构建过程的configure步骤中单独添加这些路径。
Or use CMake and a toolchain file to manage the build. More difficult still is adding native cross libraries. Usually they are stored in /usr/cross/i586-mingw32msvc/{include,lib}
and you would need to add those paths in separately in the configure step of the build process.
这篇关于将C ++应用程序从Linux交叉编译为Windows的手册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!