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. qmake LIBS variable: is it necessary to have separate win32 and unix scopes?

qmake LIBS variable: is it necessary to have separate win32 and unix scopes?

Scheduled Pinned Locked Moved General and Desktop
qmakelibswin32unix
4 Posts 4 Posters 1.7k Views
  • 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.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on 22 Jul 2015, 09:42 last edited by
    #1

    I am working on legacy code that has a lot of the following in its qmake .pro files:

    win32 {
        LIBS += SomeCoolLib.lib \
                SomeOtherLib.lib
    }
    
    unix {
        LIBS += -lSomeCoolLib \
                -lSomeOtherLib
    }
    

    Adding or removing libraries to LIBS means that I have to add or remove things at two places in this .pro file. Since the libraries are the same for both windows and unix, i was wondering if I can write this shorter. I am using Qt 4.8, so reading the docs at http://doc.qt.io/qt-4.8/qmake-variable-reference.html#libs I found that I can probably replace the windows and unix scope by this one scope if I use the -l option:

    LIBS += -lSomeCoolLib \
            -lSomeOtherLib
    

    However, on the same documentation page, the Note recommends against this and advises to explicitly specify the library to be used by including the .lib file name suffix, which would again mean having two scopes.

    If the libraries on windows and unix are the same, then is there a way to specify them only once? Or should I stick with the two scopes and use .lib for windows and -l for unix?

    A 1 Reply Last reply 23 Jul 2015, 04:20
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Jul 2015, 22:31 last edited by
      #2

      Hi,

      It depends on the situation you have at hand. If you need to link to a specific version of a library then go with the scopes otherwise you don't need to.

      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
      • B Bart_Vandewoestyne
        22 Jul 2015, 09:42

        I am working on legacy code that has a lot of the following in its qmake .pro files:

        win32 {
            LIBS += SomeCoolLib.lib \
                    SomeOtherLib.lib
        }
        
        unix {
            LIBS += -lSomeCoolLib \
                    -lSomeOtherLib
        }
        

        Adding or removing libraries to LIBS means that I have to add or remove things at two places in this .pro file. Since the libraries are the same for both windows and unix, i was wondering if I can write this shorter. I am using Qt 4.8, so reading the docs at http://doc.qt.io/qt-4.8/qmake-variable-reference.html#libs I found that I can probably replace the windows and unix scope by this one scope if I use the -l option:

        LIBS += -lSomeCoolLib \
                -lSomeOtherLib
        

        However, on the same documentation page, the Note recommends against this and advises to explicitly specify the library to be used by including the .lib file name suffix, which would again mean having two scopes.

        If the libraries on windows and unix are the same, then is there a way to specify them only once? Or should I stick with the two scopes and use .lib for windows and -l for unix?

        A Offline
        A Offline
        alearner
        wrote on 23 Jul 2015, 04:20 last edited by
        #3

        @Bart_Vandewoestyne
        i think what you want is

        win32 {
            somecool  = SomeCoolLib.lib 
                    someother = SomeOtherLib.lib
        }
        unix {
            somecool = -lSomeCoolLib 
                   someother =  -lSomeOtherLib
        }
        
        LIBS += somecool \
                someother 
        
        1 Reply Last reply
        0
        • N Offline
          N Offline
          NetZwerg
          wrote on 23 Jul 2015, 05:24 last edited by
          #4

          As soon as paths or library names differ, you will have to use scoped declarations. Otherwise it really does not matter. Win32 also links correctly using -lSomeCoolLib, therefor you could just use one LIBS directive.

          1 Reply Last reply
          0

          1/4

          22 Jul 2015, 09:42

          • Login

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