开发者

Way Cross Compile C/C++ code to run on Windows, Linux, and Mac OS?

Is there a way to take my C++ code and cross compile it to run on Windows, Mac开发者_StackOverflow社区 OS, and Linux? Is there a tool to do this, or does it have to be manually compiled on each OS via Terminal/Cygwin?


The easiest way is to use a Mac OS X machine with VMs for Linux and Windows (using e.g. Parallels or VMware Fusion). You can put the source code in a directory which is shared with the VMs and then use the native tools for each OS to compile it.


You can cross compile with what is known as a cross-compiler. Mingw can be installed as such. I believe MacOS just uses g++ so you can probably make a cross compiler for it as well. Never done it myself. You can scour the web for directions. Here's the top link I got from google:

http://linux.bytesex.org/cross-compiler.html


You should go through your code and convert as much as you can to ANSI C++. Factor remaining platform dependent code into separate modules. These modules may need to be rewritten for other platforms, and let the build tool select the appropriate modules. The remaining code should compile with few problems on the other platforms.

Also, verify that your GUI, if you are using one, is cross-platform compatible. Otherwise it will be a mess to convert to the other platforms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜