qt qmake conditional libs based on platform
-
Hi
in .pro file I havewin32
{
LIBS += -lole32
}and in linux it still wants to add that lib?
So syntax is incorrect or wont work for LIBS ? -
wrote on 21 Oct 2015, 09:14 last edited by
Actually the syntax is incorrect:
when adding conditional libs you have to indicate the name of the system where the lib will be needed, for example:
win32: LIBS += -lole32
else:unix: LIBS += -lole32 -
so this syntax
win32
{}
only works for includes / files?
win32 {
SOURCES += paintwidget_win.cpp
} -
wrote on 21 Oct 2015, 09:21 last edited by
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!
-
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.
-
@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.
-
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.
@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 ? -
@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,
@mostefa ole32 is a Windows specific library, as far as I know there is no such library for Linux
-
well actually I ended up with
win32: LIBS += -lole32
else:unix: LIBS += -luuidbut it was just me not understanding the real syntax with
win32 {
}
as I did
win32
{
}
which is not the same. :) -
@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.
-
wrote on 22 Oct 2015, 08:38 last edited by
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)
3/12