View Full Version : Qt Creator Assigning different compiler
hibbity
11th May 2011, 18:19
LunarCloud's Cross-Platform Qt template is a start but...
How can I change to a different compiler when running QtCreator (2.1.0) in Ubuntu.
For example, instead of the default (gcc/g++) I may want to use a cross-compiler
(i586-mingw32msvc-gcc/i586-mingw32msvc-++).
Selecting Tools-->Options gives no such options.
Build/Run Target Selector only gives Debug/Release options.
I notice that the Nokia Qt FAQ has the following:
Q: You say I can program for multiple platforms with one source tree with Qt. Do I need cross-compilers or special tools?
A: Qt uses native compilers such as gcc (Linux) or Visual C++ (Windows) on the
targeted platforms. There is no need for special cross-compilers or additional
tools.
Um. Maybe users *want* to cross-compile? Is it possible to cross-compile? Do I need the full SDK?
wysota
12th May 2011, 06:50
It should be enough to setup your toolchain in the Tools/Options/Qt4 configuration panel by directing Creator at a version of qmake prepared for your cross-compiler environment. Other than that you can do it on a per-project basis by changing the -spec parameter that gets passed to qmake.
hibbity
17th May 2011, 20:17
I tried this, per the tutorial found here: http://silmor.de/29
The newly created spec configuration file:
/usr/share/qt4/mkspecs/win32-x-g++/qmake.conf
contains this line:
QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain
which becomes an entry in Makefile.Debug as "-lmingw32 -lqtmaind"
and in Makefile.Release as "-lmingw32 -lqtmain"
Then, to compile:
make -f Makefile.Release
make: Entering directory `/x/users/<username>/qtwindows/qt_win_test'
/usr/bin/i586-mingw32msvc-g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mwindows -Wl,-s -Wl,-subsystem,windows -o release/qt_win_test.exe release/main.o release/mainwindow.o release/moc_mainwindow.o -L'/usr/lib' -lmingw32 -lqtmain -lQtGui -lQtCore
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lqtmain
collect2: ld returned 1 exit status
make[1]: *** [release/qt_win_test.exe] Error 1
I am using the open source version of Qt version 4.7 on Ubuntu 11.04
Qt was installed by "sudo apt-get install qtcreator", not by compiling source files.
This build is failing because neither of qtmaind nor qtmain exist.
Perhaps it is a licensing issue?
I'm confused. Could really use some help.
wysota
17th May 2011, 20:27
You need Qt compiled for the platform you wish to compile for. Qt for Linux/g++ is different than Qt for Windows/MinGW.
hibbity
18th May 2011, 17:52
I'm assuming 'Qt' refers to the Qt SDK.
Perhaps, if compiling Qt will produce the missing qtmain, qtmaind library files.
wysota
18th May 2011, 17:57
No, Qt means Qt. Qt SDK is Qt+Qt Creator.
hibbity
19th May 2011, 18:39
Cross compiling a QtCreator C++ project in Linux, for a Win32 target requires the libqtmain library.
This library can be cross-compiled by running: qmake-qt4 -spec win32-x-g++
in the ../QtSources/4.7.2/src/winmain/ directory of the Qt SDK.
where 'win32-x-g++' is configured to use a cross compiler, e.g. i586-mingw32msvc-g++
'make release' results in static library: libqtmain.a
'make debug' results in static library: libqtmaind.a
Now, when compiling a simple QtCreator C++ project, the result is:
/usr/lib/libqtmain.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make[1]: *** [release/qt_win_test.exe] Error 1
Running 'sudo ranlib /usr/lib/libqtmain.a' does nothing.
Not sure how to proceed. Nokia claims QtCreator projects are cross-platform, but nobody said the details would be easy.
wysota
19th May 2011, 21:12
You are doing it wrong. It is not enough to build these two libraries. You need the whole Qt built with your cross-compiler.
hibbity
24th May 2011, 17:45
Found this:
http://doc.qt.nokia.com/latest/qt-embedded-crosscompiling.html
Although it is meant for embedded linux, the approach might work anyway.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.