Compile a C ++ program on Mac to run on Linux

Possible duplicate:
How to compile Mac OS X with Linux x86?

I have an application that I wrote in C ++ / SDL using the FMOD library. The application is portable and compiles without changing the code on Mac and Linux. But one annoyance is that when I want to send a version of Linux, I have to run my Linux block, copy the source code there (via a USB drive, because I do not have a network, this is an old laptop) and compile it, and then copy it again via USB to my Mac and download it.

My question is, is there a better way to do this? Ideally, I can compile an application to run on Linux directly from Xcode, where can I compile it for Mac?

+6
c ++ linux xcode macos
source share
4 answers

A quick google cross-compilation for Linux on OSX showed this page .

In fact, this was asked earlier in How to iterate over compilation from Mac OS X to Linux x86? .

+4
source share

See How to compile with Mac OS X on Linux x86? and links in it (it offers compilation for Linux running on VM, perhaps the best idea, since trying to configure cross-compilation is usually not worth the trouble and problems).

+3
source share

The risk of delivering a Duff binary package is too high to be worth the trouble trying to build it in someone else's box.

You clearly need the Linux box to pound around, checking every time you make a new version. Therefore, it will not be a hassle to build it on this box. Using a Linux VM, though, is probably a good idea, as you can make sure that the virtual machine is in exactly the same state (and known state) before each build.

I assume that you are at least going to smoke, check each issue.

+2
source share

You can statically link all the code (with all the dependencies) into a single binary file and have a version for Mac and a version for Linux.

0
source share

All Articles