How properly add external libs to Qt .pro?
-
What errors are you getting? Are they linker errors or compiler errors?
You definitely need to add library headers to
INCLUDEPATH
. That should solve compiler errors.Then if you get errors from your linker, post them here. It can be that linker can't find the library (it will simply say so then), but it can also fail to find symbols inside the library (then it will print many errors).
-
What errors are you getting? Are they linker errors or compiler errors?
You definitely need to add library headers to
INCLUDEPATH
. That should solve compiler errors.Then if you get errors from your linker, post them here. It can be that linker can't find the library (it will simply say so then), but it can also fail to find symbols inside the library (then it will print many errors).
@sierdzio said in How properly add external libs to Qt .pro?:
INCLUDEPATH
Well, i tried includepath(i found about 15 psapi.lib files on my Disk C):
QT += core gui LIBS += -luser32 INCLUDEPATH += C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64 LIBS += -lpsapi
And still same errors:
-
@sierdzio said in How properly add external libs to Qt .pro?:
INCLUDEPATH
Well, i tried includepath(i found about 15 psapi.lib files on my Disk C):
QT += core gui LIBS += -luser32 INCLUDEPATH += C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64 LIBS += -lpsapi
And still same errors:
Your INCLUDEPATH is not properly defined. Backslahses are interpret as end of lines with continuation in next line. The spaces are inpret as separators.
Try
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
In LIBS you specify library but not the path to where to find it. See here: https://doc.qt.io/qt-5/qmake-variable-reference.html#libs
-
Your INCLUDEPATH is not properly defined. Backslahses are interpret as end of lines with continuation in next line. The spaces are inpret as separators.
Try
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
In LIBS you specify library but not the path to where to find it. See here: https://doc.qt.io/qt-5/qmake-variable-reference.html#libs
-
@koahnig Still not working(even worse, 282 errors now)
QT += core gui INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64" LIBS += -luser32 LIBS += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64/Psapi.Lib"
@Engelard
Hi
Are you using visual studio compiler and not mingw ?update:
you need
#include <windows.h>
#include <psapi.h>and .pro syntax is
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
LIBS += -lPsapithen it links here.
NOTE: my path is slightly different from yours.
-
@Engelard
Hi
Are you using visual studio compiler and not mingw ?update:
you need
#include <windows.h>
#include <psapi.h>and .pro syntax is
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
LIBS += -lPsapithen it links here.
NOTE: my path is slightly different from yours.
@mrjj said in How properly add external libs to Qt .pro?:
@Engelard
Hi
Are you using visual studio compiler and not mingw ?update:
you need
#include <windows.h>
#include <psapi.h>Your order of including trigger in me some memory what i had months before(had same issue but with includes for Opengl).
What i now did.
Just replace windows include before psapi and others and it now compile with no errors, perfectly as it should. Also i tested, now no additional lines in .pro file needed. so my .pro section looks like this:
QT += core gui LIBS += -luser32
So the solution: Windows.h should be included BEFORE libs which depends on it.
-
@mrjj said in How properly add external libs to Qt .pro?:
@Engelard
Hi
Are you using visual studio compiler and not mingw ?update:
you need
#include <windows.h>
#include <psapi.h>Your order of including trigger in me some memory what i had months before(had same issue but with includes for Opengl).
What i now did.
Just replace windows include before psapi and others and it now compile with no errors, perfectly as it should. Also i tested, now no additional lines in .pro file needed. so my .pro section looks like this:
QT += core gui LIBS += -luser32
So the solution: Windows.h should be included BEFORE libs which depends on it.
-
So the solution: Windows.h should be included BEFORE libs which depends on it.
... and sane include files include everything they need, so they don't depend on any order. which seems not the case here.
-
@aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.
@Engelard said in How properly add external libs to Qt .pro?:
@aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.
Yes, we know these scenarios exist. @aha_1980 is just pointing out that such headers are not "sane" :)
-
@Engelard said in How properly add external libs to Qt .pro?:
@aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.
Yes, we know these scenarios exist. @aha_1980 is just pointing out that such headers are not "sane" :)