PDA

View Full Version : Multiple platforms



ctote
4th February 2010, 05:39
Hey guys,

I can't figure out how to move my code from one platform to another. A project I'm working on requires that the code be written on a windows machine but ran on linux/mac. Can someone tell me how I can build my application (or somehow copy the project) so that it can be distributed to a linux/mac computer?

vishwajeet.dusane
4th February 2010, 06:36
Hi

Here i am assuming few things,correct me if i am wrong.
1. You have Qt project
2. in which you do not have any platform dependent code other than Qt code. If you have platform dependent code then you can use Q_WS_WIN, Q_WS_MAC, Q_WS_X11 micros in #ifdef
3. Your Qt project has .pro file

if all the cases are correct from above then you really dn't have to very much about it. you can follow the same build process on mac and linux as you followed on windows. i.e. qmake, nmake (on windows) / make (mac and linux)

For Qt installation on Mac/Linux refer Qt site.

ctote
4th February 2010, 16:59
Thanks for the reply. I'm using Qt Creator for most of my projects -- is there a way to do it through that?

jvdl
5th February 2010, 12:43
I think there is some confusion now between compiling on the host platform and cross-compiling. Cross-compiling means that you compile the program for another target platform then the one you are compiling on (the host platform).

Qt says about cross-compiling (in the FAQ):

Cross compiling the Qt package is not something we support. Qt is not designed to be cross compiled so we don't actually test if this is possible. Due to the nature of Qt, some parts must be built natively in order for it to cross compile such as qmake, moc and uic which are used during compilation. We do not test this scenario internally and therefore do not guarantee it would work.

So you better get yourself a Mac and install linux on your pc (can be done with dual boot so you can keep windows on it). Then install Qt on both operating systems and compile!

If you don't want to do this, start searching for 'cross compiling' with google. But its probably easier to go for the first solution.

Joost

JohannesMunk
5th February 2010, 13:09
At least for the linux part I would suggest www.virtualbox (http://www.virtualbox) instead of dualbooting. You can download fully configured linux machines, so that you don't even have to install it yourself.

I just googled "virtualbox MacOSX" and came up with this forum: http://forums.virtualbox.org/viewtopic.php?t=2076 . It may be a starting point. Although the legal aspects have to be thoroughly considered!

To get back to the question: You would then install QtCreator on those platforms and compile your projects natively. So you avoid the problem of cross-compiling.

Johannes

ctote
15th February 2010, 07:46
Thanks for the replies everyone -- so I understand now that I cannot cross-compile my projects. However, is there a way to easily transfer a project written in Windows to Linux (e.g., write the project in Windows, transfer, and compile the same project in Linux)?

Thanks again for the support

nish
15th February 2010, 13:34
there is no easy way. there is only one way. just copy your whole source dir to linux machine and compile. If you dont have windows specific code like hardcoded paths ("C:\Windows", type) and win32 api calls then you are done.

ctote
15th February 2010, 17:54
Ok - we tried this but got an error. I'll post the error message next time I'm at the workstation. Thanks

schnitzel
15th February 2010, 20:48
assuming you took some care to use portable code, i.e. use Qt API everywhere to hide platform specific code or #ifdef, the process is simple.
An example to copy a project from windows to linux:
1) delete debug/release folders
2) delete Makefile, Makefile.Debug, Makefile.Release
3) delete object_script*.*
4) delete <project>.pro.user
5) copy the entire folder
6) open the <project>.pro file with Qt Creator on linux
7) build all

note: if you link any 3rd party libs, then you need to specify the differences in your .pro file like so (example):
unix:LIBS += -l/location/of/lib/linux/libwhatever.a
win32:LIBS += c:/location/of/lib/win/libwhatever.a