C ++跨平台编译 [英] C++ cross platform compiling

查看:117
本文介绍了C ++跨平台编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows 7-32bit 操作系统。

我想将我的简单C ++源代码编译为所有操作系统的可执行文件。和体系结构。

I want to compile my simple C++ source code into executable for all OSes and architectures.

我想从操作系统中为此操作系统进行编译。

I want to compile for this below operating systems from my OS.


  • Windows 32

  • Windows 64

  • Linux 32

  • Linux 64

  • OSX 32

  • OSX 64

  • Windows 32
  • Windows 64
  • Linux 32
  • Linux 64
  • OSX 32
  • OSX 64

是否可能?

注意:我需要为只有Win7 32bit的所有操作系统编译C ++。

Note: I need to compile C++ for all OSes with only Win7 32bit.

推荐答案

在目标OS上进行编译比交叉编译要容易得多。您需要的是每个操作系统的工具链和一个制造工具。 CMake具有强大的交叉编译能力。这不是必需的,但可以节省一些钱:获取虚拟化软件(例如,VMWare Player是免费的)并在其他OS上运行。

It is much easier to compile it on the target OS than cross compiling it. What you need is a toolchain for every OS and a "make" tool. CMake has powerful crosscompiling abilities. This is not a necessity, but it will save some money: Get virtualization software (e.g. VMWare Player is free) and run on a different OS.

我建议使用clang( OSX),gcc(Linux),TDM gcc(Windows)作为工具链(MSVC也不错,但不是免费的)。 32位和64位之间的区别应该不是问题。当您使用不同的编译器时,我建议您坚持使用最标准的编译器标志,以遵守该标准。

I would recommend clang (OSX), gcc (Linux), TDM gcc (Windows) as toolchains (MSVC is also nice, but is not free). The difference between 32bit and 64bit should not be the problem. When you are working with different compilers, I advise you to stick to the standard by turning the most pedantic compiler flags on at each.

我还建议您使用一个持续集成服务器,每个操作系统目标和体系结构都有一个客户端。这将减轻您在一个OS中进行的不兼容更改的痛苦。您还可以确保通过包管理器或安装程序进行安装。

I would also recommend you to have a continuous integration server somewhere with one client for every OS target and architecture. This will ease the pain of incompatible changes that you make in one OS. And you will also be able to ensure installation by package manager or installer.

只需在网络上搜索有关交叉编译,工具链和持续集成的更多信息即可。

Just search the web for further readings on cross compilation, toolchains and continuous integration.

这篇关于C ++跨平台编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆