C++ 交叉编译手册 应用程序从Linux到Windows?
是否有从 Linux 到 Windows 交叉编译 C++ 应用程序的手册?
只是。 我想要一些信息(链接、参考、示例...)来指导我做到这一点。
我什至不知道这是否可能。
我的目标是在 Linux 中编译一个程序并获得一个可以在 Windows 下运行的 .exe 文件。
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.
My objective is to compile a program in Linux and get a .exe file that I can run under Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议您尝试一下 GUB (Grand Unified Builder),因为它交叉编译了多个包它们的依赖关系并将它们组装成当前 11 种架构的单个安装包。 您可以从 此处并遵循此处的源代码。 它目前可用于交叉编译 GNU LilyPond/ GNU Denemo / Inkscape 和 OpenOffice.org。
目标架构为:
I suggest you give the following, GUB (Grand Unified Builder) a try as it cross-compiles several packages with their dependencies and assembles them into a single installation package for currently 11 architectures. You can download a prebuilt iso for installation in a VM from here and follow the source here. It can currently be used to cross-compile GNU LilyPond/ GNU Denemo / Inkscape and OpenOffice.org.
The target architectures are:
这取决于你的意思(我真的不能说)。
如果您想在 Windows 上使用现有的 Linux 应用程序,那么您可以尝试使用 Cygwin。 然而,这并不能为您提供一个摆脱对 Cygwin 的所有依赖关系的 Windows 可执行文件(您的可执行文件仍然依赖于 cygwin.dll 文件) - 并且它仍然可能需要一些移植才能工作。 请参阅 http://www.cygwin.com。
如果您的意思是您希望能够在 Linux 上执行 Windows 应用程序的实际编译并生成可在 Windows 上执行的 .exe 文件 - 从而使用您的 Linux 机器进行开发和/或编译,那么您应该查看进入 MinGW for Linux,这是一个在 Linux 上交叉编译 Windows 的工具。 请参阅 http://www.mingw.org/wiki/LinuxCrossMinGW。
此致!
It depends on what you mean (I couldn't really say).
If you mean that you want to use an existing Linux application on Windows, then you could try compiling it using Cygwin on Windows. This however does not give you a Windows executable free from all dependencies towards Cygwin (your executable still depends on the
cygwin.dll
file) - and it still may need some porting before it will work. See http://www.cygwin.com.If you mean that you want to be able to perform the actual compilation of a Windows application on Linux and produce a .exe file that is executable on Windows - thus using your Linux box for development and/or compilation then you should look into MinGW for Linux which is a tool for crosscompiling for Windows on Linux. See http://www.mingw.org/wiki/LinuxCrossMinGW.
Best regards!
基础知识并不太难:
将 apt-get 替换为 yum 或您的 Linux 发行版使用的任何内容。 这将为 Windows 生成
hello.exe
。一旦你明白了这一点,你就可以使用autotools,并设置
CC=i586-mingw32msvc-cc
或使用 CMake 和工具链文件来管理构建。 更困难的仍然是添加本机交叉库。 通常它们存储在
/usr/cross/i586-mingw32msvc/{include,lib}
中,您需要在构建过程的配置步骤中单独添加这些路径。The basics are not too difficult:
Replace
apt-get
withyum
, or whatever your Linux distro uses. That will generate ahello.exe
for Windows.Once you get your head around that, you could use autotools, and set
CC=i586-mingw32msvc-cc
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.