5

I encountered this problem when I compiled mosquitto on my Fedora 21 box from source.

mosquitto_pub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory

The clients (i.e mosquitto_pub and mosquitto_sub) keep throwing that error even with reinstallation.

4 Answers 4

9

Assuming you have installed the libraries to /usr/local/lib, which is the default, the correct answer is to run /sbin/ldconfig as root/sudo.

On some systems you will need to add /usr/local/lib to the paths that ld caches, e.g.

echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
1
  • Not sure why this isn't the accepted answer. Seems better all around and worked for me
    – Malachi
    Mar 14, 2016 at 8:01
8

I fixed this problem with sysmlinks

$vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
include /usr/local/lib
/usr/lib
/usr/local/lib
$/sbin/ldconfig
$ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1
4
  • This answer makes no sense, if your libraries are in /usr/local/mosquitto/lib, then the symlinks you have created would make no difference. If the libraries are in /usr/local/lib then just running ldconfig would update the linker cache, no need to modify ld.so.conf.
    – ralight
    Jun 16, 2015 at 10:20
  • Yes, you're right about /usr/local/mosquitto/lib. I've changed it to /usr/local/lib. About just running 'ldconfig' to update the linker cache, I did try that to no avail before having this somewhat 'dirty' solution. Jun 16, 2015 at 20:04
  • You're right, I'm suprised that /usr/local/lib isn't in the default settings for Fedora.
    – ralight
    Jun 22, 2015 at 12:00
  • this solution worked for installing mosquitto on amazon linux 2 Sep 19, 2020 at 8:09
5

This indicates that the linker does not know where to find the library. Just run sudo /sbin/ldconfig to update the linker cache of libraries. This is not something that is unique to mosquitto.

0

I installed mosquitto from source on Ubuntu 20.04. So, the libmosquitto.so.1 was in the same directory as the source files. I copied it to usr/lib/x86_64-linux-gnufolder. Then running the mosquitto_sub worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.