Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to correctly specify Qt user and system library path
kronat last edited by kronat
I'm trying to compile a set of libraries and programs with a custom Qt version (system: 5.5.1, user: 5.8.0). For the majority of them, everything works fine, except for only one.
I have correctly set the environment variables needed (proved by the fact that others compiled libraries, such as qwt, correctly shows a link to the 5.8.0 version of Qt).
So, the core of the problem is the following: the program X, which I'm trying to compile against the 5.8.0 version, has a dependency that is in /usr/lib. In the end, the generated Makefile looks like the following:
LIBS = $(SUBLIBS) -losgQt -L/usr/lib -lpython2.7 -lgdal [...] -L/home/user/Qt5.8.0/5.8/gcc_64/lib -lQt5OpenGL [...]
I have omitted others libraries linking directives with [...]. It uses the "qmake" program to generate the Makefiles. The problem is that gcc has the /usr/lib library path (added for finding the dependencies) specified BEFORE the custom Qt dir. That means that gcc will find the system Qt before the 5.8.0, calling then an error on the linking phase ((.qtversion[qt_version_tag]+0x0): undefined reference to `qt_version_tag') because the software is compiled with 5.8.0 but then linked to 5.5.1.
In the end, the answer is: how to arrange the order of the libraries path in the generated Makefile?
Actually it should look in /home/user/Qt5.8.0/5.8/gcc_64/lib for -lQt5OpenGL as there is correct -L in front of -lQt5OpenGL
Are the other libraries you're linking against linked against Qt 5.5.1?
You should check the linker command.