Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qt qmake conditional libs based on platform
Forum Updated to NodeBB v4.3 + New Features

qt qmake conditional libs based on platform

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 5 Posters 3.9k Views 2 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #3

    so this syntax
    win32
    {

    }
    only works for includes / files?
    win32 {
    SOURCES += paintwidget_win.cpp
    }

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #4

      No for me the problem is not from the syntax,

      the problem is that you specify only LIBS for win32 system,

      you need to specify the LIBS for unix too,

      Hope this can help!

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Hi,

        it's because of the line return. It should be

        win32 { #<< start of scope
            LIBS += -lole32
        }
        

        The scope of win32 starts on the line you write it. So if you add a line return, the content of your brackets fall in the global scope.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        mrjjM 1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @mostefa No it's not the problem at all. It's just a syntax error. There's no need to specify everything for all platforms.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            it's because of the line return. It should be

            win32 { #<< start of scope
                LIBS += -lole32
            }
            

            The scope of win32 starts on the line you write it. So if you add a line return, the content of your brackets fall in the global scope.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #7

            @SGaist
            Oh, that is sneaky.
            now I understand.
            just so used to
            {
            }
            being a scope that the idea never cross my mind :)
            so I made a nameless global scope ?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mostefa
              wrote on last edited by
              #8

              @SGaist ,

              I know that we can write : LIBS += -lole32

              But if we specify that win32: LIBS += -lole32

              don't we need to specify it to linux ? thank's in advance,

              jsulmJ 1 Reply Last reply
              0
              • M mostefa

                @SGaist ,

                I know that we can write : LIBS += -lole32

                But if we specify that win32: LIBS += -lole32

                don't we need to specify it to linux ? thank's in advance,

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @mostefa ole32 is a Windows specific library, as far as I know there is no such library for Linux

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  well actually I ended up with
                  win32: LIBS += -lole32
                  else:unix: LIBS += -luuid

                  but it was just me not understanding the real syntax with
                  win32 {
                  }
                  as I did
                  win32
                  {
                  }
                  which is not the same. :)

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @mostefa What you put in your scope depends on what you need. In this case it's a Windows only library that has no equivalent on Linux so no.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • Hamed.MasafiH Offline
                      Hamed.MasafiH Offline
                      Hamed.Masafi
                      wrote on last edited by
                      #12

                      Target and arch selector in qmake (I have used this in my project):

                      win32:{
                          contains(QMAKE_TARGET.arch, x86_64):{
                              PLATFORM = "win-64"
                          }else{
                              PLATFORM = "win-32"
                          }
                      }else{
                      
                          BITSIZE = $$system(getconf LONG_BIT)
                          if (contains(BITSIZE, 64)) {
                              linux*: PLATFORM = "linux-64"
                              macx*: PLATFORM = "mac-64"
                          }
                          if (contains(BITSIZE, 32)) {
                              linux*: PLATFORM = "linux-32"
                              macx*: PLATFORM = "mac-32"
                          }
                          android: PLATFORM = "android"
                          ios: PLATFORM = "ios"
                      }
                      
                      #include pri file based on platform
                      include(myproj-$${PLATFORM}.pri)
                      

                      Remote object sharing (OO RPC)
                      http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                      Advanced, Powerful and easy to use ORM for Qt5
                      https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                      1 Reply Last reply
                      1

                      • Login

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