Stack overflow地址:Manual for cross-compiling a C++ application from Linux to Windows? - Stack Overflow
翻譯:
這有跨平臺的C++程序的文檔嗎,在Linux和Window上?
就像剛才說的,我想要一些信息(鏈接,引用,示例等等)來指導(dǎo)我怎么做。
我不知道這是不是可行的。
我的目的是在Linux上編譯程序,獲得一個exe文件可以在Windows上面運行。
Answers1:
基礎(chǔ)知識不是很難:
sudo apt-get install mingw32
cat > main.c <
i586-mingw32msvc-cc main.c -o hello.exe
使用yum代替apt-get,或者你的Linux的其他工具。它將會生成 hello.exe在 Windows上運行的。
一旦你掌握了這種發(fā)放,你可以使用autotools,設(shè)置?CC=i586-mingw32msvc-cc:
CC=i586-mingw32msvc-cc ./configure && make
或者使用CMake工具鏈來管理。更難的是添加交叉庫,通常它們存儲在/usr/cross/i586-mingw32msvc/{include,lib},在組建過程中你需要分別的添加路徑到配置文件中。
Answers2:
我建議你使用下面的,GUB嘗試使用它們的依賴性交叉編譯多個包,并將它們組裝到當(dāng)前11個體系結(jié)構(gòu)的單個安裝包中。你可以下載一個預(yù)先安裝iso來安裝在虛擬機里(網(wǎng)址),或者下載它的源碼(網(wǎng)址)。它目前可用于交叉編譯GNU LilyPond / GNU Denemo / Inkscape和OpenOffice.org。
目標體系架構(gòu)如下:
darwin-ppc - tar.bz2 file for Darwin 7 (MacOS 10.3)/PowerPC
darwin-x86 - tar.bz2 file for Darwin 8 (MacOS 10.4)/x86
mingw - mingw executable for Windows32
linux-x86 - shar archive for Linux/x86
linux-64 - shar archive for Linux/x86_64
linux-ppc - shar archive for Linux/PowerPC
freebsd-x86 - shar archive for FreeBSD 4/x86
freebsd-64 - shar archive for FreeBSD 6/x86_64
cygwin - .tar.bz2 packages for Cygwin/Windows32
arm - shar archive for Linux/ARM (largely untested)
debian - shar archive for Debian (largely untested)
Answers3:
這取決于你的真正意思(我不能很確定):
1.如果你的意思是使用一個存在的Linux程序在windows上,你可以嘗試在Windows上使用Cygwin進行編譯。它不會給你一個沒有任何依賴于Cygwin的可執(zhí)行文件(你的可執(zhí)行程序仍然依賴于cygwin.dll),并且需要一些移植,它才可以工作。看http://www.cygwin.com/。
2.如果你想在Linux上執(zhí)行一個windows上編譯的可執(zhí)行文件或者產(chǎn)生一個exe文件在Windows上執(zhí)行,使用你的Linux機器開發(fā)或者編譯你需要看一下MinGW在Linux上,它是一個跨平臺編譯工具對于Windows和Linux來說。參考:http://www.mingw.org/wiki/LinuxCrossMinGW。