Need some help with Cross Compile basics
-
Hello Everybody!
I'm new to QT, but have been using MSVC for a decade. I've created a small app for a good starter project with QT. I've got the entire QtSDK installed on Windows 7 32 bit. The Project is built (with no errors or warnings) with Mingw that came with the SDK. On Windows everything is fine, but the whole point (for me) of using QT is Code once, Deploy Everywhere, right? Well, I've been 2 days now trying to cross compile this project for Mac OSX ... I even tried installing Qt on OSX (a Virtual Machine in VMware) but as if to say: you're going down the wrong path, Qt Creator wasn't installed and all the components like designer fail to execute. The OSX version is 10.6.4, not the latest, so I gave up on that. I've been able to create/add a Build Configuration of Qt 4.7.3 Mingw for OSX targets were I could specify what I guess is a valid ABI using the Settings Drop-downs, but the Tool-chain only ever shows Mingw for Windows targets. I've also tried running QMake for Qt Command Line, which the SDK put in the Start Menu. The Qmake line I used had -spec macx-g++ and did make a 'makefile' but executing mingw32-make gave an error about 'test' so who knows what going on there.
I figure I'm missing something very basic. The original project was converted in VS 2008 Pro with the Qt plugin/addon. Originally the project was a Visual Studio- MFC project that I used the Qt plugin to create the .pro and .pri files and from there have been working in Qt Creator. It just occured to me: Maybe this is the source of the trouble? The QtSDK seems to come with everything I'll need to cross compile for Mac and most major Linux Distros/Kernels/Desktop, so Why do I only get Qt 4.7.3 (Mingw) for WINDOWS targets as a tool chain option in the tool chain drop-down in project settings?
I'll try recreating the project from a Blank, new Qt Creator created Qt Widget Project, and see if the project options open up any new avenues for cross compiling. Meanwhile, If one of the Qt Guru's could give a real basic 'how to' take a sample project that comes with QtSDK and go from Windows Host build to Mac OSX build. I fould a Doc page on how to do this from the command line using GCC (not Mingw) for Embeded Linux. The Key thing seemed to be specifying the -xplatform mkspec directory to the particular .conf file using the configure utility. Issue: that's GCC, not Mingw that comes with the SDK, so what is the Mingw equivalent of configure? Still, It seems some folks put a lot of effort into the Qt settings dialog in Creator including the command line 'builder' with the line of drop-downs for building up a qmake cmd line, so why can't I make use of it? The Spec always comes out for win32-g++ and the tool chain of Mingw for OSX never shows up. Do I need a version of Qt for OSX? is that's what's missing? Is it in the SDK?
Thank You in Advance -
... well, I tried making a new Qt Widget App (Qt GUI App) and had the same restrictions. In Targets, under Build settings the tool chain drop down only specifies Mingw as a GCC for Windows Targets, even though the Manually created Tool Chain for OSX was specified which has the ABI spec for maxos ...
-
I can't help with cross compilation itself (my knowledge here is very limited), especially on Windows, but have a few tips that might help you with your problem:
Since, as I gather, you do have access to a Mac machine, why do you try installing Qt SDK on a virtual machine? Install the native Mac OS version and compile your code there (and yes, for most projects there will be no need to change the code). I work on Linux, but I've did that trick to get Windows exe files for my projects a few times and it works brilliantly
AFAIK, mingw is just a Windows port of GCC, so it may happen that the instructions for compilation are the same (again, just guessing)
Don't be surprised most of the tutorials are about GNU/Linux and GCC - that is the primary platform used for development Qt itself. Cross compilations from Linux to other unix-like OSes works smoothly (Android for example, and I know some people do compile for Windows from within GNU/Linux). Windows is considerably different in almost every aspect, so maybe it's harder to get it to compile for unix-like.
As I've said, I'm no expert here, those were just some more or less random thoughts. Best way for now is probably to simply install the SDK on Mac and compile there.
-
Thanks for the reply. I already tried to install Qt on MAC, but Qt creator didn't install and what did, like Assistant, won't execute. I guess I'll try updating OSX to the latest updated version and then try reinstalling Qt. If that does not work, I'll try installing the whole SDK, but I was hoping to avoid the 1.3 GB download, as the Web installer didn't work. Things not working could be because it's a VM... not sure. Still, This seems like the wrong way to do this. Download and install QT into every Flavor of OS I want to deploy to? Cross-Compiling seems like a much better thing to be doing.
Does anyone know what the appropriate cmd line for Mingw32-make should include. My command line approach did have partial success. I copied the QMake line from the effective cmd line text box in Qt's project-targets setting dialog, pasted it into the Qt Cmd window and edited the -spec from win32-g++ to macx-g++ ... it did make a 'MAKEFILE' without errors or warnings. Then I ran cmd mingw32-make with no switches or parameters ... seems like at least an output directory should have been specified.
I'll try again and let folks know how it goes. -
Can't help you with that, sorry.
Try asking on "interest mailing list":http://lists.qt-project.org/mailman/listinfo or IRC, there are lots of experts there, too.
[EDIT: fixed link, Volker]
-
Qt works flawlessly with OS X 10.6.4. I did not try the SDK with that very version, but it runs on my 10.6.8 which is compatible.
Cross compilation on a Windows box using MinGW to target Mac OS X is, to my knowledge, not possible. And I doubt if it is possible - and legal - at all, as you would need to link against OS X specific system libraries (notably the Carbon and/or Cocoa frameworks), which are not available outside a OS X machine.
It does not help to fiddle around in mkspecs, by doing that you do neither get the correct compiler version (Apple has its's own patched gcc and tool chain to support universal binaries) nor the libraries needed.
To my knowledge, the only cross compilation supported out of the box by the SDK is for mobile devices. For everything else you will have to setup things manually, including installation for the correct toolchain and libraries and building Qt manually.
The easiest solution would be to build the Mac version on a OS X box. Give up on trying to target OS X on a Windows box.
If you are running your OS X installation in a virtual machine (you do know that for OS X 10.5 and 10.6 this is only allowed for server versions, not the desktop versions, and only on Apple hardware, don't you?) then make sure, you have selected a 64bit processor as guest architecture, as the SDK and all prebuilt binaries contain x86_64 code only.
-
Thanks Volker... not I didn't know any of what you said.
So Apple has made it such that I have to buy Apple HARDWARE if I want to make FREE software that runs on their platform?!?! :-)
Well, now it's a no-brainer... Give up on EVER making ANYTHING that runs on Mac!
Well, I'll target Linux instead. My Friends can try to get a Linux App to run on their Macs, and I'll wish them luck (I've heard it's supposed to work, but for what flavor of Linux?)
So lets forget about OSX.
Any tips for cross compiling from Windows Host to Linux Target? I know this is kind of broad, as there are so many versions of Linux Kernals/Desktops/etc.
So far, I've discovered, from examining the resultant MAKEFILE, that the -spec informs qmake about the HOST OS and Not the Target OS. The MAKEFILE had defines the were Linux shell comands in it, not DOS cmds...
If there are posts already on this topic, Just links would be helpful.
Thanks Again. -
Sorry if my questions are (admitately) very basic. I've been searching for 2 days for some basic answers and usually when it takes a long time to find the answers it's either too exotic a question or too simple (as in everyone knows that, right?)
What I'm posting now is for the benifit of other nubies, so that hopefully other folks don't have so much trouble finding the simple answers:
Thanks Volker for just simply letting us nubies know: It can't be done (cross-compile to Mac target) due to needing Cocoa on the host.
So far what I've found is that Targeting FreeBSD with Gnome desktop is about as close as we're going to get without actually getting Mac Hardware.
As for cross-compiling on Windows host to Linux target, the advice is forget about it.
"http://www.developer.nokia.com/Community/Discussion/showthread.php?224026-Steps-to-cross-compile-Qt-Application-for-LINUX-from-Windows":http://www.developer.nokia.com/Community/Discussion/showthread.php?224026-Steps-to-cross-compile-Qt-Application-for-LINUX-from-Windows
... so my next step is to install Qt in a VMware FreeBSD VM, copy over all the source code files and build it there. Once I get that working, I'll send the results to a friend who has a mac and see if it works. I'll let folks know how it goes.