PDA

View Full Version : Cross Compiling from windows to Mac and Linux



janton
28th February 2011, 13:31
Hey All,

We work on a project, untill now almost everything is written in QT4.7.1/C++
So it should work on all platforms where qt nomally should work. For so far I know we don't use any windows special ingredients. We try to keep it cross platform overall.

I'm not the developer but i was hoping to get some information so i know how we can continue. (because the developer does not have any experience with Mac OS X)

We are developing in VS2008 on windows. I know how to build a windows version. But how can we build a Mac OS X version? We did have to "make" qt from source to work with vs2008 on windows.

I have a MAC available to test on, but prefer not to install any software on it (it's my sisters) So i was hoping we could build - cross compile - create the Mac OS X version on the windows machine and only test on these machines. Also i could try to make a vmware Mac OS test environment.

Also how about windows redistributible?
If we want to run our Release application on a fresh windows machine we have to install vs2008 redistributables. I can't find any any information about this for the Mac OS? (And perhaps we want to build a linux version later on...)


Overview:
-How to cross compile? (especially for Mac)
-redistributables on the Mac OS?

"BumbleBee"
28th February 2011, 15:52
Oh..seriously?
So in order to make an app. cross it has to be re-complied on each platform?
I thought you compile it once and use it at any OS...

ars
28th February 2011, 16:23
For getting an impression what it means to set up a cross development environment you may look at http://silmor.de/39. This is a series of 3 articles describing step by step a cross compiler environment running under linux and generating code for windows. It's not exactly what you want, but it may give you some idea of the steps you need to take.

When you are going to set up a virtual machine for testing, why don't you set up one for compiling too? I could imagine this is less effort than creating and validating a self built cross environment.

janton
28th February 2011, 18:43
Ok so the easiest would be to just create the Mac OS x version right on the Windows VMWare environment with a IDE and QT on that Mac/VWMare... ?

ars
28th February 2011, 19:28
I haven't done it myself. But in case I had to work for Mac and could not get access to Mac hardware, that would be the way to go.
You can get free gcc compiler for MAC (just Google for it) and Qt Mac download contains QtCreator according Nokia WEB site, so you automatically get an IDE.

If you are working on a commercial project, you should also estimate the time needed to set up a Mac environment in a virtual machine and compare it to the cost of Mac hardware. Maybe you can convince your employer buying a Mac.

janton
28th February 2011, 22:37
I just googled some around and this last forum question answered it well:
http://stackoverflow.com/questions/4839350/best-practices-for-cross-platform-development-with-qt


I quote:


Qt's tagline is:

Write once, compile everywhere.

With this in mind, Qt doesn't officially offer any out of the box solution for cross compiling Qt applications from a specific platform to other different platforms. Though definitely do-able, if much work and time is invested, Qt good common practice would suggest you to build your Qt application directly on the targeted platform. That means, build your the Windows target for your application an a Windows machine, your Mac target on a Mac machine and Linux target on a, you guessed right( :-) ), a Linux machine.

That's way "Write once, compile everywhere", in my opinion is a very well chosen combination of words. Otherwise the tag line might have been, "Write once, compile for everything".

Going back to the original issue, you don't even need different physical machines for each of the targeted platforms, since in this day and age of good Virtualization solutions you can easily set up a couple of virtual machines and build you app on different platforms from the same physical machine.


and


Bottom line--do what you indicated. Get your source on each target platform and compile it there.