PDA

View Full Version : No such file or directory...?



Radek
2nd January 2014, 17:13
Because of bugs, I was forced to download, fix and compile a shared library. Trying to run an application from the Creator, I am now getting an error:


/home/radek/Desktop/C++/project/repdf-debug/repdf-qt: error while loading shared libraries: libpodofo.so.0.9.1: cannot open shared object file: No such file or directory

But the library exists for sure. In /home/radek/podofo/lib are sitting libpodofo.so (a link) and libpodofo.so.0.9.1 side by side. My *.pro file now contains:


LIBS += /home/radek/podofo/lib/libpodofo.so

I have checked (using Krusader) that there are no hidden blanks around the name, that the link is a valid link, that the library looks like a shared library, that the access rights both of the link and the library are the same as usual access rights from /usr/lib and that I am the owner both of the link and of the library. I also tried to reference the library directly:


LIBS += /home/radek/podofo/lib/libpodofo.so.0.9.1

Nothing helps. No such file or directory. What is happening?

-----------------------------------

Never mind, problem solved. It's a matter of libpath, the directory specified in LIBS seems to be irrelevant at runtime. So I created "mylib" folder in /home/radek, a /etc/ld.so.d/mine.conf file containing /home/radek/mylib, copied libpodofo.so files there, updated the profile file. It works now.

ChrisW67
2nd January 2014, 20:06
You could also just add /home/radek/podofo/lib to the LD_LIBRARY_PATH environment variable in the Qt Creator project settings. You generally would need to create this variable but it may already exist. It is a colon (:) separated list of extra directories to search for dynamic libraries at run time.

Radek
3rd January 2014, 20:24
It is better to have a library specified per project and not modifying the libpath globally by /etc/ld.so.conf.d but I haven't found any way of setting LD_LIBRARY_PATH locally for a project. There is no entry in Tools -> Options -> Environment, there is no "Build options", no "Run Options" in Debian Creator. There is an unintuitive way still:

(1) Right click the project header in the project tree
(2) Select "Add Library"
(3) Select "External Library", "Next"
(4) Enter the library name including the full path (use "Browse" for it)
(5) Enter include path for library headers (use "Browse" for it or clear the line. This field can be empty)
(6) Finish

You get several ugly lines in the *.pro file. You can cleanse them. The key point: the declaration of the library seems not to be:


LIBS += /home/radek/podofo/lib/libpodofo.so

but it must be:


LIBS += -L/home/radek/podofo/lib/ -lpodofo


At least, this works after removing the mine.conf from /etc/ld.so.conf.d and deleting the contents of /home/radek/mylib . I will see whether it will work tomorrow, after restarting Debian:p

ChrisW67
4th January 2014, 21:01
In Qt Creator open your project. Click the Projects tool in the left bar. The run environment (and build) environment, including adjusting the PATH and LD_LIBRARY_PATH, for this project can be set here.

The options under Tools menu Option are not project specific.