How can I tell qmake where the Qt libraries are?



  • I have a folder in my project directory which contains all the qt libraries that my qt application needs to link to. Now I want to persuade qmake to replace the line "-L/import/soft/dist/qt-lgpl/qt-5.2.0/x64-linux2.4-gcc45-gcc/lib", which is the default, with the project local directory, i.e. "-L../lib". How can this be done?



  • In your QMake properties, you need to use the following syntax:
    LIBS += -Lpathtoyourlib -lyourlibname

    Also, you can use INCLUDEPATH += to include and directories where headers may lie to link to your dlls.

    Deployment will be a little different though since it only knows to look in the path where your executable lives.

    In linux you will need to set or append to the environment variable LD_LIBRARY_PATH with the directory of your libs, that way when the application loads it knows to look for the dlls in the directory.

    In windows its PATH and QT_PLUGIN_PATH environment variables.



  • @dvez43
    The libraries in question are the Qt libraries. Qt5Core Qt5Network etc.
    So qmake will add the library path and library name to the linker command line. I can not control this via LIBS. There must be some variable that I can set that will tell qmake where I expect it to find Qt5Core etc.
    Something like QMAKE_LFLAGS_QT_DLL=../lib (which doesn'T work for me).


  • Moderators

    Hi,

    Why do you need to change the directory? Is this for building your program, or running it?

    When building, you should use your development libraries (from the place where you installed Qt). You shouldn't have any Qt libraries in your project directory.

    If you want to run your built program, see http://qt-project.org/doc/qt-5/linux-deployment.html


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.