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

There are 4 answers

4
user1048839 On BEST ANSWER

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
1
ralight On

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
0
user3503711 On

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!

0
Milap Jhumkhawala On

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.