Qmake cannot find libraries
-
I am using Qt Creator 6.0.1 on linux (Cinnamon). I previously compiled and ran the same project without any issues, just using g++ and linking to the same libraries with pkg-config. I now want to use Qt just to make a GUI for my program.
I am unable to link 2 system libraries for my project in Qt Creator. No matter how I try to link them, qmake fails to build because it cannot find them. First, I tried using pkg-config by adding the following to my .pro file:
QT_CONFIG -= no-pkg-config CONFIG += link_pkgconfig PKG_CONFIG_PATH=:/usr/lib/x86_64-linux-gnu/pkgconfig PKGCONFIG += sndfile PKGCONFIG += jack PKGCONFIG += soundtouch
But I just get a "jack development package not found" error message and it doesn't compile. Strangely, it finds sndfile, but not the other two. Also, it cannot find the system header files that I refer to, even if I explicitly put the full path from root in quotation marks. To troubleshoot, I tried using LIBS+=... and INCLUDEPATH+=... instead of pkg-config, but that didn't work either.
So then, just to get it to compile, I tried manually adding each library .so file using right-click "Add Library", but in the file browser that pops up, many of the libraries in my /usr/lib/x86_64-linux-gnu/ folder are simply not there! (I can clearly see them when I use the file manager). It seems to me that the problem is that for some reason certain files in the root directory are invisible to Qt Creator and qmake. If I copy these same files to my project folder in the home directory and try to add them there, I can add them just fine. Same story with the header files in usr/include/.
Does anyone know why this might be happening and how to fix it?
-
@dhaus said in Qmake cannot find libraries:
PKG_CONFIG_PATH=:/usr/lib/x86_64-linux-gnu/pkgconfig
Are you sure the
:
before the path is correct? -
The
PKG_CONFIG_PATH
is an environment variable so you need to add it before running qmake.
So set it throughProjects > Build Settings > Build Environment
in QtCreator or set it through terminal before runningqmake
manually in terminal.Then add following lines in your
.pro
file:mac { #if you need to specify PKG_CONFIG = /usr/local/bin/pkg-config } #someone says this need in some Qt versions but not need in my Qt 5.12.12 QT_CONFIG -= no-pkg-config CONFIG += link_pkgconfig PKGCONFIG += protobuf \ grpc \ grpc++
I can't find a way to set environment variable in
.pro
file. Can you do it?