Desarrollo de aplicaciones Qt en sistemas Unix usando Qt Creator

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: 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.

preguntado el 08 de enero de 11 a las 16:01

3 Respuestas

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.

Respondido el 10 de enero de 11 a las 01:01

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

  QMAKE_LFLAGS += -Wl,--rpath=/home/projects/my_libs/

info on rpath is here: rpath

espero que esto ayude, saludos

Respondido el 09 de enero de 11 a las 07:01

Isn't using RPATH bad practice, though, because it overrides the dynamic linker? - Jake Petroules

Yeah, you're right, using rpath is sometimes seen as evil / bad practice, but in this case I didn't find any other suitable solution for the problem; so I guess there was no choice but to use it or run my stuff using launcher scripts - serge_gubenko

Just using this:

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

It's sloved my problem too.

Respondido el 16 de Septiembre de 16 a las 05:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.