Developing Qt applications in Unix systems using Qt Creator

Jake Petroules picture Jake Petroules · Jan 8, 2011 · Viewed 7.3k times · Source

I'm developing a Qt application in Linux using Qt Creator (2.1 RC). I've created 2 projects, and used the wizard to add the library project to the application project. However when I run it, I receive the error:

/home/jakepetroules/silverlock/silverlock-build-desktop/desktop/silverlock: error while loading shared libraries: libsilverlocklib.so.1: cannot open shared object file: No such file or directory

Is there some qmake variable I can set so that Qt Creator will set up the environment properly to run? It's quite annoying to have to copy all the files to another directory with a launcher script just to be able to test the build. On Windows it works perfectly - Qt Creator automatically adds the directories containing the DLLs to the PATH when it runs your application (where running it from Explorer would say DLL not found). Mac OS X is even worse, having to run install_name_tool on everything...

So how can I set up my qmake files so everything works right from the run button in Qt Creator? Kind of hard to debug without this ability, too.

Answer

serge_gubenko picture serge_gubenko · Jan 9, 2011

I've had a similar problem running qt apps with QTCreator on my linux machine. I've solved it by adding following lines to the .pro file of the client application:

unix:LIBS += -L/home/projects/my_libs/ -lmy_lib

unix:{
  QMAKE_LFLAGS += -Wl,--rpath=/home/projects/my_libs/
  QMAKE_LFLAGS_RPATH=
}

info on rpath is here: rpath

hope this helps, regards