Add dynamic linker path of project library for running in Qt Creator



  • Hi there,

    this is something that puzzled me for quite a while now. Consider this scenario: The current project consists of a dynamic library, an application and a unit test suite. Both the application and the unit test are linking the dynamic library. It is added to the .pro file using -L <path> -l <library>. The projects compiles and links just fine. The debug and release build directories, both out of source, siblings of the project directory, have been set up by Qt Creator.

    Now when trying to run the application (or the test), the dynamic library is not found and the program aborts during dynamic linking. The workaround is to set the (DY)LD_LIBRARY_PATH variable before starting Qt Creator. The problem with that is that it breaks switching between the debug and release builds.

    Does anybody know a way to specify in the QMake project file that the program target does not only link the dynamic library, but also needs it in the dynamic linker path when starting the application? Or (less preferred) tell Qt Creator to automatically take care of it?

    Thanks,

    Mirko.
    PS (for motivation): CMake handles that nicely.



  • What you probably want to do is add paths to the rpath. Here are "forum topics tagged with rpath":http://developer.qt.nokia.com/search/tag/rpath



  • Thanks, Bradley. I think RPATH is not a good solution for various reasons, one of them being that it is Unix only. The other problem is that RPATH is for deployment, not for development.

    What this thread boils down to is that it is not possible to select a debug or run configuration from within Qt Creator if the project is multi-part and contains dynamic libraries that are re-used later in the project. I think this is a mess that definitely needs a good solution.

    Do any of the Qt Creator folks have a good idea?



  • I think Qt Creator is supposed do this for you, but I have found that it does not always work. (See e.g. "this thread":http://developer.qt.nokia.com/forums/viewthread/6789.)

    What you can do is set LD_LIBRARY_PATH in the Run Environment in Qt Creator. This is different for different builds, so it should be possible to set different values for debug and release builds.



  • Granted RPATH is only a solution for Unix. But why is it only for deployment? Why couldn't it be used for altering library loading of a development build, just as it would for a deployment build?



  • @Bradley: Agreed, RPATH can be used for development as well. It is probably more of a gut reaction to not "abuse it" for development.

    @ludde: Setting LD_LIBRARY_PATH and PATH and DYLD_LIBRARY_PATH (and whatnot :-) ) is what I am doing as a workaround. Thanks for the pointer to the Qt Creator thread.

    I will check with the Qt Creator guys if automatically setting the library path for debugging is supposed to work. If so, I guess the current behavior is simply a bug. Thanks!


Log in to reply
 

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