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.

user1048839
  • 938
  • 3
  • 9
  • 24

4 Answers4

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
ralight
  • 11,033
  • 3
  • 49
  • 59
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
user1048839
  • 938
  • 3
  • 9
  • 24
  • 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 '15 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. – user1048839 Jun 16 '15 at 20:04
  • You're right, I'm suprised that /usr/local/lib isn't in the default settings for Fedora. – ralight Jun 22 '15 at 12:00
  • this solution worked for installing mosquitto on amazon linux 2 – ᐅdevrimbaris Sep 19 '20 at 08: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!

user3503711
  • 1,623
  • 1
  • 21
  • 32