cross compiling

I was originally gonna post this in response to seth’s question at http://forum.openframeworks.cc/t/cross-platform-of-download/1534/1, but then thought it would be hijacking the thread so posting it separately.

Does anyone have experience with cross compiling? Building an exe for windows straight from my xcode would be ace :stuck_out_tongue: gcc is supposed to support it, and I’m sure it can be dodgy as hell. But it could still be quite handy if the project files were setup with the right options if possible…

it can be done, but don’t know exactly how :), i googled about some time ago and seemed complex for what i remember.

also some time ago was taking a look at cmake and it seems it supports cross compiling, so it should be easier than just trying to setup gcc

what do you mean by cross-compiling? just posix systems or also for windows?

i am sure you can tell gcc to create a win32-ABI-compatible exe, but you are lacking the libs. why not just setup some makefiles (maybe via cmake) or project files (msvc, codeblocks, …) and copy the solution + compile on demand? i am sure it would be very convenient but i am also sure you can drink a coffee and smoke a cigarette while copying the source files and hit compile?! :wink:

hmmm, look what i found in my delicious bookmarks - interesting…
http://kuon.goyman.com/2008/08/18/mingw-…-m-macos-x/

if you go the other way. other useful tools:
http://code.google.com/p/badgerconfig/
http://www.tilander.org/aurora/2007/10/-…-onfig.html
http://premake.sourceforge.net/

what do you mean by cross-compiling? just posix systems or also for windows?

yea, compiling for linux and windows, straight from my mac. I"d obviously need the libs (maybe even precompiled oF libs for all platforms). I could test the binaries through bootcamp or parallels, but I just don’t want to use codeblocks and actually develop on other platforms (i know debugging won’t work with this method, but I’m neglecting those problems for now).

Yeah, sounds like this fits in some with my proposal for a cross-platform OF download.

Still, sounds like a big mess if done from source. On the other hand doing this in conjunction with precomiled oF libs sounds very feasible and awesome.

for linux:

  
  
sudo apt-get install mingw32-binutils mingw32 mingw32-runtime  

download codeblocks-additions for windows and copy lib contents to:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/

and include contents to:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include

in codeblocks, under settings > compiler & debugger

select gcc and press copy, then in toolchain-executables > program files substitute:

g++ with i586-mingw32msvc-g++
ar with i586-mingw32msvc-ar

in toolchain-executables > aditional paths add:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include

and voila, windows codeblocks projects just compile in linux, you will have some issues with some incorrect capitalisation, or \ instead of / but it works.

for mac: http://nyctergatis.com/gcc/mingw.html

configuring codeblocks should be more or less the same than under linux.

JFYI, fedora linux and mingw are your friends …
https://fedoraproject.org/wiki/Features-…-s-compiler