Results 1 to 9 of 9

Thread: How to determine target architecture in qmake project file?

  1. #1
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Question How to determine target architecture in qmake project file?

    Hi

    Does somebody know if it is possible to determine which target architecture is used in the qmake project file?
    To clarify: I don't want to determine the architecture of the operating system used when building the application, I need the target architecture of the executables/libraries to be built.
    I'm using Qt 5 and GCC (as compiler on Linux) and mingw (as compiler on Windows).

    I already read the qmake Variable Reference (http://qt-project.org/doc/qt-5.0/qtd...reference.html) but found nothing useful. The only useful variables I found "have only an effect on Mac OS X".

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine target architecture in qmake project file?

    What do you mean by target architecture? Unless you are cross compiling the Linux/GCC combination will build for Linux, and Mingw for Windows, in whatever bit-ness your Qt library was built with. You can separate the two in a PRO file with win32 {} and unix {} scopes.

  3. #3
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to determine target architecture in qmake project file?

    By target architecture I mean the CPU architecture (x86, AMD64, ARM, ...), not the operating system (I know the win32/unix scopes).

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine target architecture in qmake project file?

    What are you trying to achieve in the PRO file that needs to know this?

  5. #5
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to determine target architecture in qmake project file?

    I want to add the right libraries (depending on the target architecture).
    If I'm using libraries provided by a Debian package like lcrypto (from OpenSSL) the right library is chosen automatically.
    If I want to add one of my own libraries I need to give the (relative) location of the library additionally to its name. Here I need different locations depending on the target architecture. Do you think there is a better way to achieve that the right library is picked automatically (like when using a library provided by a Debian package)?

    And thanks for the quick answer :-)

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine target architecture in qmake project file?

    These libraries of yours are not built as part of the same project with the same settings?
    Are you cross compiling?

    I think on Windows you can use QMAKE_TARGET.arch to tell "x86" from "x86_64" but that does not exist on Linux.
    On Linux something like this might get you there:
    Qt Code:
    1. linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
    2. linux-g++-32:QMAKE_TARGET.arch = x86
    3. linux-g++-64:QMAKE_TARGET.arch = x86_64
    To copy to clipboard, switch view to plain text mode 
    Lifted from : http://qt-project.org/faq/answer/how...bit_or_a_64_bi
    Last edited by ChrisW67; 27th December 2013 at 03:00. Reason: Added some stuff

  7. The following user says thank you to ChrisW67 for this useful post:

    Infinity (11th January 2014)

  8. #7
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to determine target architecture in qmake project file?

    Are you cross compiling?
    No

    These libraries of yours are not built as part of the same project with the same settings?
    No, these libraries are build separately (using separate project files). But not because I need them to be built separately. I just didn't know that it is possible to build needed projects/libraries together with the project that uses them.
    How do I achieve that (that would solve my problem in a more elegant way)? How to tell qmake which header/source files belong to each library? Do I need to add the project files of the libraries to the project that uses them? If that assumption is correct, how do I do that properly?

  9. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine target architecture in qmake project file?

    You use a subdirs project. For a simple example project.pro:
    Qt Code:
    1. TEMPLATE = subdirs
    2. SUBDIRS = foo bar app
    3. CONFIG += ordered # makes sure libs foo and bar are built before app
    To copy to clipboard, switch view to plain text mode 
    with a source tree like:
    Qt Code:
    1. - project.pro
    2. + foo
    3. - foo.pro
    4. - a.cpp
    5. - etc...
    6. + bar
    7. - bar.pro
    8. - b.cpp
    9. - etc...
    10. + app
    11. - app.pro
    12. - main.cpp
    13. - mainwindow.cpp
    14. - etc...
    To copy to clipboard, switch view to plain text mode 
    The app.pro could reference the libraries:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET = MyCoolProgram
    3. INCLUDEPATH += ../foo ../bar
    4. LIBS += -L../foo -lfoo
    5. LIBS += -L../bar -lbar
    6. ...
    To copy to clipboard, switch view to plain text mode 
    and a library PRO would look like:
    Qt Code:
    1. TEMPLATE = lib
    2. TARGET = foo
    3. SOURCES += ...
    4. HEADERS += ...
    To copy to clipboard, switch view to plain text mode 

    Done from memory, check the qmake manual.

  10. The following user says thank you to ChrisW67 for this useful post:

    Infinity (27th December 2013)

  11. #9
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to determine target architecture in qmake project file?

    Thanks for helping. I will try to use a subdirs project tomorrow.

Similar Threads

  1. Share my qmake project file
    By ibingow in forum Qt Tools
    Replies: 0
    Last Post: 30th August 2011, 10:19
  2. Replies: 1
    Last Post: 4th December 2009, 00:34
  3. qmake can't process project file on windows
    By s-troz in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2008, 15:51
  4. making qmake create VisualStudio console app project file?
    By akos.maroy in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 15:45
  5. qmake: detecting x86_64 architecture?
    By akos.maroy in forum Qt Programming
    Replies: 3
    Last Post: 2nd August 2008, 12:26

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.