Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Building projects for 32 and 64 bit Windows on 64 bit machine
Forum Updated to NodeBB v4.3 + New Features

Building projects for 32 and 64 bit Windows on 64 bit machine

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 3 Posters 13.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    ludde
    wrote on last edited by
    #1

    Trying to make it possible to build my project for both 32 and 64 bit Windows from my 64 bit Windows 7 machine, using two different Qt 4.7.2 builds. This works fine as long as I don't need to do different things in the .pro file for 32 / 64 bits, but since I want to link with some external libraries, which are in different locations for 32 and 64 bits, I need a way to distinguish between 32 and 64 bit builds in the .pro file.

    "This FAQ entry":http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi describes a way to distinguish between 32 and 64 bit builds using QMAKE_HOST.arch. But that does not really work if you want to enable both 32 and 64 bit builds on a 64 bit machine, since it only tells you the architecture you are building on, not for.

    The easiest way to accomplish what I want would of course be to have different mkspecs for the two Qt builds, but that is not how building Qt for 64 bit Windows works, at least not at the moment. I'm using Visual Studio 2008, so for me both builds are built using the win32-msvc2008 mkspec. I tried introducing my own mkspec win32-msvc2008-64 by just copying the existing win32-msvc2008 mkspec. That did not work at all, though - seems like qmake and/or configure has some built-in knowledge about the different mkspecs.

    The only solution I could come up with that actually works is to build some knowledge about the Qt installation directories into the .pro file, like this:

    @QT_INSTALL_PREFIX = $$[QT_INSTALL_PREFIX]
    X64 = $$find(QT_INSTALL_PREFIX, 64)
    isEmpty(X64) {
    ...
    } else {
    ...
    }@

    This works, as long as the 64 bit Qt is installed in a directory with a path that contains 64, and the 32 bit Qt is not.
    A bit ugly, but the best I could come up with. Any ideas on how to improve this, or do it in some other way, are most welcome.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      Does using QMAKE_TARGET.arch help? It is not really documented, but you can find some notes on it here:

      http://bugreports.qt.nokia.com/browse/QTBUG-9160

      We have also added the following FAQ for this:

      "FAQ for QMAKE_TARGET.arch":http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi

      1 Reply Last reply
      0
      • L Offline
        L Offline
        ludde
        wrote on last edited by
        #3

        That does help, in fact it does exactly what I was looking for. Thanks a bunch!

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pip010
          wrote on last edited by
          #4

          in risk of being a tr0ll here, but : going with CMake seems most elegant. At least for me, since Qt is the only dependency falling off my build toolchain :)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved