Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set library path for qtcreator in Ubuntu ?
Hi, I develop software with QtCreator 4.10.2 on Ubuntu 18.04.
It works greatly.
The project is managed by cmake. and the qt version is 5.9.
But I encountered problems when I tried to debug the program.
The message in "Application Output" is
error while loading shared libraries: ***.so: cannot open shared object file: No such file or directory
If I started the program from terminal, the program works normally
I tried to clear build-directory of project and delete *.user in source directory, but the problem still exists when I rebuild project from source
I manually add library paths into
Projects->Run->Run Environment, it still doesn't work.
I manually add library paths in to
Kitconfigurations, it still doesn't work.
If manually add
Projects->Run->Run Environment, it works.
So, What should I do to let qtcreator load
One way is to start it from the console where you defined that variable.
However if you defined it system wide, it should be picked up automatically unless you modified the environment.
Note that PATH has nothing to do with library loading on Linux. It's only for executable discovery.
@SGaist Yeah, I set LD_LIBRARY_PATH for target libraries. And I even reboot ubuntu for several times, but the problem still exists.
I start QtCreator from dock.
Can this be the reason ?
How did you set that variable ?
By the way, what is that library ?
@SGaist my project requires some 3rd libraries to run. Such as qt, vtk, and etc.
First, I set
~/.bashrc, which doesnot work, just as I explained before
Then, I manually add
LD_LIBRARY_PATHin (current open project of QtCreator)
Projects->Run->Run Environment, it works. Just as step 5 shown.
I start QtCreator from
Can this be the reason ?
I set LD_LIBRARY_PATH in ~/.bashrc
Can you show how exactly you're doing this?
laine last edited by laine
@jsulm I set with following code in
export PATH=$PATH:~/libraries/qt-5-91/5.9.1/gcc_64/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/libraries/qt-5-91/5.9.1/gcc_64/lib export QTDIR=~/libraries/qt-5-91/5.9.1/gcc_64
By the way, if I start qtcreator from shell, it works.
paulf last edited by paulf
Personally I advise against using LD_LIBRARY_PATH in any situation. Here is an example of why you should not do this. At work we use an in house build of GCC that is badly done and relies on LD_LIBRARY_PATH. If I use our standard setup, then I can't execute qtcreator because there is a conflict in the versions of libstdc++ caused by our LD_LIBRARY_PATH. If I unset LD_LIBRARY_PATH, I can run qtcreator fine. But then when I try to build any software, our tools that need their LD_LIBRARY_PATH don't work. In this case I can add the LD_LIBRARY_PATH to the build environment. Alternatively you end up with each app being launched with a wrapper script that sets LD_LIBRARY_PATH.
There is a better way. RPATH. See this topic on SO. Effectively this bakes in the correct library search path into your executable.
JonB last edited by JonB
I don't know if this is your problem/you are already aware, but do you understand that
.bashrcis not always read? It's only read in when
bashis started interactively (like a terminal shell). Do you need to check if your