Results 1 to 9 of 9

Thread: Assigning different compiler

  1. #1
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Assigning different compiler

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Assigning different compiler

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Assigning different compiler

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Assigning different compiler

    You need Qt compiled for the platform you wish to compile for. Qt for Linux/g++ is different than Qt for Windows/MinGW.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Assigning different compiler

    I'm assuming 'Qt' refers to the Qt SDK.

    Perhaps, if compiling Qt will produce the missing qtmain, qtmaind library files.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Assigning different compiler

    No, Qt means Qt. Qt SDK is Qt+Qt Creator.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Assigning different compiler

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Assigning different compiler

    You are doing it wrong. It is not enough to build these two libraries. You need the whole Qt built with your cross-compiler.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Assigning different compiler

    Found this:
    http://doc.qt.nokia.com/latest/qt-em...compiling.html

    Although it is meant for embedded linux, the approach might work anyway.

Similar Threads

  1. Strange compiler behaviour (compiler passes wrong argument)
    By SasaVilic in forum General Programming
    Replies: 2
    Last Post: 2nd November 2010, 11:36
  2. question about assigning a pixmap to an icon
    By Dark_Tower in forum Newbie
    Replies: 5
    Last Post: 21st December 2009, 09:11
  3. Replies: 1
    Last Post: 1st June 2009, 20:58
  4. Assigning QActions without a QMenuBar nor toolbars
    By elcuco in forum Qt Programming
    Replies: 1
    Last Post: 14th October 2008, 18:35
  5. Replies: 2
    Last Post: 17th July 2007, 17:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.