Cross-Compiling from Windows to ___

BlitzMax Forums/BlitzMax Programming/Cross-Compiling from Windows to ___

CoinOpBard(Posted 2010) [#1]
Hello Blitz Max forum people - I've got a bit of a problem.

I have a game which I've programmed in Blitz Max on a windows machine, which I would like to port to Mac and Linux. I know that to do that you're supposed to compile ON a Mac or Linux OS. Unfortunately I don't have regular access to either of those systems, and, from what little I've been able to try, setting up Blitz Max on them seems to be a finicky task.

My question is - can I cross-compile from Windows to Mac/Linux? I've seen guides on cross-compiling from Mac or Linux to WINDOWS, but not the other way around. Have I just missed something obvious? Or is this going to be difficult?

Any help would be welcome, specific steps for cross-compiling for Mac or Linux would be extra welcome, and for BOTH you get this genuine limited edition Cyber-Awesomeness-Award (valued at $99.99 on Farmville).

Thanks!


ima747(Posted 2010) [#2]
There is no simple way to cross compile from win to mac/linux. The only cross compiling I'm aware of at all (and use all the time) is mac can cross compile to windows using brucy's BMX2 and maxide CE (community edition) from mac (and I believe from linux as well).

It might be possible to some how get a cross compile from windows to linux, but to go to mac would be very tricky. Mac applications are actually folders containing a structure including the binary and some other data files, and they are VERY picky about their file permissions, which get crushed on many drive formats used by windows. As such even moving an application through a windows machine can sometimes kill it. Though it's not as bad as when macs relied entirely on resource forks which meant if they touched just about anything but a mac FS the application would just get crushed.

Additionally when you cross compile you have the issue of testing. Which in my experience is always complicated when the initial development was done on windows. Primarily because windows BMX defaults to direct X while mac and linux only have the option of OpenGL. Graphical anomalies can and do result between the drivers. There are plenty of other issues cross platform (maxgui layouts as one more glaring example) so you HAVE to test on the other system extensively even if you never compile on it. Macs are the easiest to test FROM because a) it's the only "platform" that can run Mac OS b) the hardware can booth either OTHER platform c) there are plenty of virtual machine suites that are very robust to the extent you can do much of your prototyping in a virtual boot of the other OS (though always ALWAYS do a real boot, the graphics drivers in most of the virtualization suites especially are not so reliable with a lot of BMX stuff)

So, if you want to compile for mac, you WILL need a mac (and I highly recomend an intel based one, not an old PPC based one since only intel can build for intel and PPC, PPC can only build for PPC and therefore would need to be run through the PPC translator on any even remotely new mac. It's not installed by default any more so any new user is going to be confused as to why they have to install Rosetta to run your program...). If you want to compile for linux you can likely just dual boot it (linux can run off a flash drive, external drive, or even a CD if you really don't have any rewritable media around...). If you run anything OTHER than windows you should probably be able to build for windows too, and it will also simplify your testing.

Some simple problems you might find when building for multiple platforms
Windows: Runs direct X by default so graphics WILL look a bit different on other platform unless you explicitly use the opengl driver. File paths use a backslash as a dividing character, though blitzmax seems to handle the translation 99% of the time, sometimes like with some modules, it comes and bites you.
Mac: Window layouts seem to be much more finicky with maxgui, but maybe that's just me. Not used nearly as much as windows so some OS specific bugs fall through the cracks. You should be aware of the processor architecture(s) you're building for...
Linux: VERY picky about case in includes for modules etc. Graphics drivers of the os sometimes pose serious hassles. Least used (it seems) target OS, so even more so than mac there are OS specific bugs that fall through the cracks. Sometimes you have to modify modules, or choose one that's appropriate for the linux build you're targeting (mainly graphics system related)

It's not just fire and forget for another OS, but it is a HELLUVA lot easier than re-writing from scratch, or even meshing existing code with a new OS's libs etc. :0)


Gabriel(Posted 2010) [#3]
Additionally, if I understood right, BMax on Mac requires XCode, which isn't available on other platforms. BMax on Windows uses GCC, which is available on Linux and Mac. So that may be part of the reason that it works one way and not the other.


CoinOpBard(Posted 2010) [#4]
Thanks ima747 for your thorough reply and Gabriel for your comment.

I guess I'll just have to go take another look at setting up BlitzMax on Linux and Mac.


ima747(Posted 2010) [#5]
To continue clarifying, xcode is apples developer bundle but it uses GCC (for now at least I think they want to move to their own modified variant but I don't recall the details...). However compiler aside the OS libs for mac are tightly bundled unlike linux (open source all the way...) and windows (just generally well known at this point so you can get in without any hassle).

And I forgot to mention linux and mac can also run wine (darwine on mac) to run windows executables without a full OS install of windows, which for mac at least is critical for the cross compile... haven't cross compiled from linux myself but I believe that it requires a wine install as well (basically proving access to the windows underpinnings without the OS).

It's not that it's not possible from a technical standpoint to compile from windows to other things, but there's no publicly available method and it's FAR harder (due to lack of tools etc.). Linux and Mac are used to having to do the work for some sort of windows compatibility so there's lots of middleware solutions to help. Windows is used to be being top dog and pretending nothing else exists, so it's harder to break out :0)

One more note, linux and mac can both boot from external drives (unlike windows) so an external USB hard drive and you can make your own development toolkit you can bring to whatever computer might be available if you don't have your own mac, or box you'd like to run linux on... just a thought. Just install and boot off the drive, install any other tools you need (like xcode for mac), then bmax and you're ready to plug and go. Mac installs are not very hardware dependent since the OS holds basically all the standard drivers so you can swap a mac pro drive into a laptop and it'll boot fine. Linux will be a bit more finicky, but it's still not like windows which will re-install every driver for every peice of hardware the drive goes to (and the drive needs to be installed...)

Last edited 2010


SLotman(Posted 2010) [#6]

One more note, linux and mac can both boot from external drives (unlike windows)



Of course you can boot Windows from external drives... I even have an old "Vista LiveCD" somewhere here.

There's even some tutorials on how to do this online: http://articles.techrepublic.com.com/5100-22_11-5928902.html

As for the rest, it's mostly true. You can't cross-compile on Windows to Mac. Linux should be possible, but still, not very practical.

Anyway, you could try to install Linux and MacOS on a USB drive, and run from there - or even install a Virtual Machine, and do the same, under windows. Won't be the same as having a full installation, but wouldn't hurt either.

With Linux you can also shrink your Windows partition, and install Linux there, with grub, so you can boot to whatever OS you like. It's pretty easy - I've done it myself here.

Last edited 2010