Cross Compiling for Windows and Mac from Linux

There are many tools available in this day and age to target multiple operating systems, but its not as simple as copy paste config run... It actually takes many hours of trial and error, so I thought I'd write about the joys and pain of my cross compilation experience.

http://mxe.cc/ has done loads of work in order to target windows environments from Linux, but what about OSX? After loads of googling, I found that most projects have given up cross compiling OSX, which is quite unfortunate... I managed to stumble upon https://github.com/tpoechtrager/osxcross... The developer seems to be very active, and has loads of scripts and documentation to get you going :)

Not having very much experience myself in this area, I decided to start playing around with this, and of course everything I've done will be used in Shadow, for our gitian builds... For some reason I was losing all my symbolic links every time I repackaged the MacOSX SDK.. Eventually I wrote a script to rebuild it, and YAY! I got Qt to cross compile for Mac :D

If I had know a bit more about OSX, llvm and clang, I would have identified the issues allot quicker, so I must say this exercise has broadened my knowledge and skill set more than I'd have imagined!

The people in #qt on freenode weren't really pleased that I was asking for help cross compiling for OSX, so I knew it had to be done by myself... All the gitian scripts available on the interwebs seem rather out-dated, or have some secret knowledge behind them which no one is willing to share :(

Sure it would of been allot easier if I just too dasource's advice months ago and used http://travis-ci.org, but this was a challenge to me, and I felt that I had to get it done before I could move onto some new tool that would make life allot easier...

For windows it's rather easy.. Install mingw-w64 and g++-mingw-w64, set your host, set your target, configure and compile... QtWebKit is another story though.. it requires loads of dependencies to compile, and the make files have some mkspec files have some .exe's in them, and so on.. tends to get a bit messy, luckily we just had to do a search and replace for some executables, and replay some defines with hard coded values, and we were set and on our way :)

One thing I realized though this exercise, is the value of documentation... Most projects have tons of documentation, but for cross compilation there is very little available. This whole exercise has made me realize that we do need solid documentation, as our APIs aren't really super easy to use, and our code isn't that easy to understand.. I see the value in documentation, as its now bitten me hard enough times.

I just want to say thanks to all those people contributing on http://doc.shadowproject.io/, helping us get some documentation in place, a step in the right direction!