I am trying to compile a project in my system using qmake. Some dependencies of the project are not installed but reside in my home directory, more or less like this: libs files: /home/myusername/local/lib
and my includes directory /home/myusername/local/include
. Inside the include directory I have a folder, qjson
with the needed headers from the library. In the lib folder I have the files libqjson.so libqjson.so.0 libqjson.so.0.7.1
.
My qmake project file looks something like this:
linux-g++ {
INCLUDEPATH += /home/myusername/local/include/
LIBS += -L/home/myusername/local/lib/ -lqjson
}
and the generated makefile will produce commands like this one:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB \
-DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../qbuzz \
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui \
-I/usr/include/qt4 -I/home/myusername/local/include/ -I. -I. -I../myproject -I. \
-o qbuzz-result.o ../myproject/myfile.cc
It is clear that my include directory is in the -I
option of gcc. myfile.cc
contains an include like this one:
#include <qjson/parser.h>
However, after running make, I get the error:
../myproject/myfile.cc:2:26: fatal error: qjson/parser.h: No such file or directory
compilation terminated.
Now, if I modify the environment variable CPLUS_INCLUDE_PATH
to add my local include file, I have no problems there, but in the linker stage I got the error:
/usr/bin/ld: cannot find -lqjson
collect2: ld returned 1 exit status
Even though the linker command was:
g++ -omyprogram main.o mainwindow.o myfile.o moc_mainwindow.o -L/usr/lib \
-L/home/myusername/local/lib/ -lqjson -lQtGui -lQtNetwork -lQtCore -lpthread
I also can get around modifying the environment variable LIBRARY_PATH
. However I am looking for a solution that relies on modifying as few environment variables as possible, and after all, why are the options -L and -I there?
I works on Windows without problems using MinGW g++.
I notice that the QT's automatic include paths have no trailing slashes, and yours do. Have you tried writing the paths without trailing slashes?
linux-g++ {
INCLUDEPATH += /home/myusername/local/include
LIBS += -L/home/myusername/local/lib -lqjson
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With