简体   繁体   English

在Windows上运行并生成Linux代码的C ++编译器

[英]C++ compiler that runs on windows and generates Linux code

我只是好奇这是否可行:是否有在Windows上运行的C ++编译器并且可以生成Linux代码?

Absolutely it's possible. 绝对是可能的。 You need a compiler that can handle cross-compilations and then specify the target. 您需要一个可以处理交叉编译然后指定目标的编译器。 The key point is to get a compiler that's capable of creating the binary files in a manner required by the target system. 关键是要使编译器能够以目标系统所需的方式创建二进制文件。 g++ would do just that for you. g ++会为你做到这一点。

I worked on a project where we used linux to create embedded arm executables using their C compiler, and then used scp to copy it over for testing. 我参与了一个项目,我们使用它来使用他们的C编译器创建嵌入式arm可执行文件,然后使用scp将其复制以进行测试。

Yes it's possible, but why bother? 是的,这是可能的,但为什么要这么麻烦? There is a risk that you will set it up incorrectly and get a binary which doesn't work correctly. 您可能会错误地设置它并获得无法正常工作的二进制文件。

Plus also, you'll need vmware** installed so you can test the resulting binaries - you are going to run comprehensive tests, aren't you? 此外,您还需要安装vmware **,这样您就可以测试生成的二进制文件 - 您将要运行全面的测试,不是吗?

Simply set up another VM to do the building (because of course, you need to test that it will work on a machine without the build-tools installed). 只需设置另一个VM来进行构建(因为当然,您需要测试它是否可以在没有安装构建工具的情况下在计算机上运行)。

** Other virtualisation platforms are available, this is not a commercial. **其他虚拟化平台可用,这不是商业广告。

There are also libraries such as this one: http://www.shlomifish.org/open-source/portability-libs/ that provide portability between platforms. 还有像这样的库: http//www.shlomifish.org/open-source/portability-libs/ ,它们提供平台之间的可移植性。 For other ones I suggest looking for abstraction libraries 对于其他我建议寻找抽象库

如果你有足够的CPU,你应该得到VirtualBox ,只需安装kubuntu或任何其他发行版,虽然听起来可能很复杂,但测试二进制文件和调试它们会更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM