Question

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.

Was it helpful?

Solution

Yes, Creator has a section where you can set whatever environment you need for running your app.

On Creator 2.0.0 this is accessed by: Projects -> Targets -> (your target) -> Run -> Run Environment (after you have opened your project)

You can then add or remove any environment variables you'd like, including LD_LIBRARY_PATH One thing I'm not sure of is if it is possible to substitute e.g. the build path into the value of those variables, so that you don't have to hardcode that into your LD_LIBRARY_PATH.

Another option would be to add a small shell script to your source tree which sets whatever variables are necessary, and add a "Custom executable" run configuration to run that script. That's accessed through the same screen.

OTHER TIPS

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

Just using this:

unix:LIBS += -L/home/projects/my_libs/ -lmy_lib
unix:{
  QMAKE_LFLAGS += -Wl,--rpath=/home/projects/my_libs/
}

It's sloved my problem too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top