user1048839
user1048839

Reputation: 958

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

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.

Upvotes: 5

Views: 16001

Answers (4)

user3503711
user3503711

Reputation: 2046

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!

Upvotes: 0

Milap Jhumkhawala
Milap Jhumkhawala

Reputation: 327

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.

Upvotes: 5

ralight
ralight

Reputation: 11608

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

Upvotes: 9

user1048839
user1048839

Reputation: 958

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

Upvotes: 8

Related Questions