Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to correctly specify Qt user and system library path
Forum Update on Monday, May 27th 2025

How to correctly specify Qt user and system library path

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kronat
    wrote on 6 Mar 2017, 11:14 last edited by kronat 3 Jun 2017, 11:35
    #1

    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?

    Thanks!

    J 1 Reply Last reply 7 Mar 2017, 06:16
    0
    • K kronat
      6 Mar 2017, 11:14

      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?

      Thanks!

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Mar 2017, 06:16 last edited by
      #2

      @kronat said in How to correctly specify Qt user and system library path:

      -L/home/user/Qt5.8.0/5.8/gcc_64/lib -lQt5OpenGL

      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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      1/2

      6 Mar 2017, 11:14

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved