BMK NG - Cross-compile OS X -> Win32

BlitzMax Forums/BlitzMax NG/BMK NG - Cross-compile OS X -> Win32

Brucey(Posted 2009) [#1]
Subtitle : Building Win32 BlitzMax binaries on Mac.

Heh... I couldn't help myself..

Executing:bmk.debug
Compiling:blitz_app.c
/usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc -w -march=pentium -ffast-math -fno-exceptions -c -Os -I/Applications/BlitzMax/mod/brl.mod/blitz.mod -I/Applications/BlitzMax/mod  -o /Applications/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz_app.c.debug.win32.x86.o /Applications/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Compiling:blitz_types.c
/usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc -w -march=pentium -ffast-math -fno-exceptions -c -Os -I/Applications/BlitzMax/mod/brl.mod/blitz.mod -I/Applications/BlitzMax/mod  -o /Applications/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz_types.c.debug.win32.x86.o /Applications/BlitzMax/mod/brl.mod/blitz.mod/blitz_types.c
Compiling:blitz_cclib.c
/usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc -w -march=pentium -ffast-math -fno-exceptions -c -Os -I/Applications/BlitzMax/mod/brl.mod/blitz.mod -I/Applications/BlitzMax/mod  -o /Applications/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz_cclib.c.debug.win32.x86.o /Applications/BlitzMax/mod/brl.mod/blitz.mod/blitz_cclib.c
Compiling:blitz_memory.c
...
...


(I'm sure Marc guessed I wouldn't be able to keep away from the idea - just to see)

:-p


Brucey(Posted 2009) [#2]
well... knock me over with a very large feather...

It actually works! :-)


Tommo(Posted 2009) [#3]
I guess you're going to write a remote debugger next.
Then you can build on Mac, debug on Mac, but run on Win. : d


Brucey(Posted 2009) [#4]
I guess you're going to write a remote debugger next.

Of course, I have to assume you were joking there :-p


DavidDC(Posted 2009) [#5]
Amazing!


slenkar(Posted 2009) [#6]
very good laddie


xlsior(Posted 2009) [#7]
I'm very impressed. :-)
Definitely deserves to be part of the official install.

So, what's next? Getting Linux to compile on Mac as well for a one-stop-shop? :-)

I guess building Mac on windows is pretty much out of the question, thanks to XCode?


xlsior(Posted 2009) [#8]
Oh, just of out curiosity: Does this mean that you can also compile the windows modules under Mac now?


Brucey(Posted 2009) [#9]
Does this mean that you can also compile the windows modules under Mac now?


Official modules build fine.
Some of mine are a bit of an issue with this newer GCC - the libraries themselves. But I'm looking into it. (For resolving - try a full gcc 4.3.x build on Windows... see if the same mods have problems there - I would expect so, but you never knows).
But most of them build fine.

It actually took me longer to get the Universal build (PPC build on Intel) working, than it did to set this up. But then, I'd already refactored the important parts already by then, so there were only a few new things to support.
The biggest challenge for bmk was replacing the ?win32 sections with conditional code - given that one needs both sets of code available on Mac...

A very interesting project.

But I don't think it's something Joe Coder will want to try - considering what needs to be installed and configured to get it to work. (well, there's not that much really, but it requires a bit of effort which some people won't trouble themselves with).
Of course, for those that *really* want to do it this way, assuming my directions were adequate, I think it should take about 20 mins to get everything installed and configured and the build started. (maybe less).


Brucey(Posted 2009) [#10]
*sigh*

I suppose if I rather went with GCC 3.4.5 (the one that's current for BlitzMax, my life would be a little easier). It's also available, so perhaps I should stick with it for now.

But... it's been an eventful process anyway - seeing what libs are GCC 4 friendly on Windows. Most of them are fine. Only a few require some configuration tweaks to get them to build without errors. And hopefully my changes are backwards compatible :-p


... okay... am rebuilding for 3.4.5 - 3 mins to download... a couple of mins to change the build configuration for bmk (it's in a separate file).
Fingers crossed it gets to the end without barfing.


xlsior(Posted 2009) [#11]
Good luck. :-)


Brucey(Posted 2009) [#12]
Okay... all modules built fine with 3.4.5. Yay :-)


Brucey(Posted 2009) [#13]
I've got a new MaxIDE with all the new build options now :



:-)


Armitage 1982(Posted 2009) [#14]
Woaw !
This is something I would like to see In Windows or Linux too :D

What's exactly made this possible on Mac and not on the 2 others platform Bruce ?


Brucey(Posted 2009) [#15]
What's exactly made this possible on Mac

The general availability of a Mac binary package of MinGW, which is designed to generate Windows binaries.
Essentially it is the same MinGW you are using on Windows, except that it has been compiled to *run* on Mac.

It is also available for Linux, so in theory it could work there too. (i.e. build Win32 binaries on Linux)


TommyH(Posted 2009) [#16]
Gernot Frisch, the coder of GLBasic (www.glbasic.com) manages it just the other way around: his IDE runs under Windows only and he is able to generate Mac and Linux executables on the Windows platform!

Hmm, I wonder if Brucey can find out how he does it ;-)

Great work, Brucey! Could be the right time to buy a used Mac as a universal build machine...


Brucey(Posted 2009) [#17]
Hmm, I wonder if Brucey can find out how he does it

You mean, like downloading it and seeing what's in the Compiler folders?

I see what he's done.
Essentially, he has a copy of a GCC toolchain for each target platform (with minimal supporting shared-libraries).
Very interesting...

It's almost tempting to lift those GPL binaries out of there and try them in BlitzMax :-p


Grisu(Posted 2009) [#18]
True Awesomeness!


TommyH(Posted 2009) [#19]

You mean, like downloading it and seeing what's in the Compiler folders?


Unfortunately none of you can see that big smile on my face :-)

Come on, Brucey, get tempted ;-)

You're da man already, can you beat yourself?


Brucey(Posted 2009) [#20]
I just thought... it's not going to work.

We need a windows binary of bcc for Mac, as I expect the assm that bcc generates for Mac is different to that which it writes for Win32.
Of course, if someone tells me I'm wrong.. then I'll admit I'm wrong :-p


xlsior(Posted 2009) [#21]
We need a windows binary of bcc for Mac, as I expect the assm that bcc generates for Mac is different to that which it writes for Win32.


...That might be something that BRL could generate/compile, right?


Brucey(Posted 2009) [#22]
Yep. I was going to ask Mark.. but he's probably really busy.


degac(Posted 2009) [#23]
Wow. Fascinating!

(PS: In your post there's a screenshot showing MaxIDE window opened...what's Framework Bah.pyro? A particle engine-library?)