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.
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