qmake LIBS variable: is it necessary to have separate win32 and unix scopes?
-
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?
-
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.
-
@Bart_Vandewoestyne
i think what you want iswin32 { somecool = SomeCoolLib.lib someother = SomeOtherLib.lib } unix { somecool = -lSomeCoolLib someother = -lSomeOtherLib } LIBS += somecool \ someother