I am trying do deploy a application. I created a *.deb package (using fpm) which installs libraries to $HOME/.local/lib/nca and binaries to $HOME/.local/bin.

To make my libraries visible I also installed a conf file to /etc/ld.so.conf.d/ which consistes solely of a line $HOME/.local/lib/nca and a newline. When I try to run the application, it complains that it can't open libraries. Problem goes away if I set LD_LIBRARY_PATH to $HOME/.local/lib/nca.

So I ran ldconfig -v and first thing that I saw is this: /sbin/ldconfig.real: Can't stat $HOME/.local/lib/nca. But the directory is there, calling stat on it works perfectly fine.

How can I make ldconfig see my deployed libraries?

Ubuntu version 18.04.

EDIT: As requested:

$ ldconfig -v
/sbin/ldconfig.real: Can't stat $HOME/.local/lib/nca: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu` given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu` given more than once

And then it lists libraries for directories as usual. I tried to run it both as sudo and not. Only difference in output that I noticed is that non-sudo prints "Can't create temporary cache file /etc/ld.so.cache~: Permission denied".

LD_LIBRARY_PATH was set using indirect path: export LD_LIBRARY_PATH=../lib/nca, I did not check if it works with $HOME.

EDIT2: When I edited /etc/ld.so.conf.d/nca.conf and changed $HOME to /home/marpan (so that full path was /home/marpan/.local/lib/nca), things worked. ldconfig -v no longer complained but listed all the libs in the aforementioned path and my executable ran.

  • @EliahKagan When I edited /etc/ld.so.conf.d/nca.conf and changed $HOME to /home/marpan, ldconfig worked! So hoorray, step forward. Although it's a bummer I can't use $HOME there, because now I would have to figure out if I can run a post-installation script that figures out user's home directory and outputs proper path to nca.conf. If you want to post "You can't use enviroment variables in ldconfig conf files", I feel like I should accept that as an answer ;) But if you have more insight, I'm all ears. – MarPan Aug 25 '19 at 17:15
  • A script can add a line to nca.conf. Shell scripts expand $HOME (though you have to think about what user the script runs as). If you edit again with current nca.conf contents and (if any) the current post-installation script, a full answer should be possible. But I think a better way may be to install the files elsewhere. .deb packages, installed system-wide, shouldn't put files in user-specific locations (except for accounts created just to run the packaged software, and even then, rarely with executable and library files). You may want to explain why you're doing it that way. – Eliah Kagan Aug 25 '19 at 17:55
  • You are right about installing to user-specific location. I tried to do it this way because of previous problems, before I learned how ldconfig works. Now I think I should go back to putting executables to /usr/bin and libraries to /usr/lib/nca (I'm deploying custom Qt libraries and I don't want to put them in /usr/lib because I'm afraid I might overwrite something). This way I shouldn't need any post-installation scripts. – MarPan Aug 25 '19 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.