79

I have installed protobuf by using following commands:

./configure
make
make check
make install

However when I run protoc I get following error:

protoc: error while loading shared libraries: libprotoc.so.8: cannot open shared object file: No such file or directory
Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169

4 Answers4

263
sudo ldconfig

or

export LD_LIBRARY_PATH=/usr/local/lib

should solve the problem.

Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
  • 3
    @Bagzerg `protoc` needs to know where to look for shared libraries. (It cannot search your whole system). This is similar to how `PATH` helps in locating executables. See this [post here](https://unix.stackexchange.com/a/45106/19506) that explains `LD_LIBRARY_PATH`. – Kshitiz Sharma Feb 18 '15 at 13:29
  • as of Feb 2016, installed protocol-buffers 2.6.1 on debian 8, and this solved the problem for missing libraries. Thanks @KshitizSharma – Leonardo Brambilla Feb 18 '16 at 16:57
  • i used the second method "export..." , but i dont know why the first method doesn't work. – lirui Mar 09 '16 at 07:16
  • 3
    Thanks. It did the job. However, I think, it is more appropriate to use this: `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib` – ponir Jun 09 '16 at 18:07
  • 1
    Lol for me restarting the machine fixed the problem – Martin Kosicky Mar 25 '18 at 20:55
  • @ponir This depends on whether there are multiple temporary paths after the user logs in.Mostly, `export LD_LIBRARY_PATH=/usr/local/lib` is much cleaner. – Crawl.W Jun 17 '21 at 06:57
10

You can also use

$ sudo ldconfig # refresh shared library cache.

as stated at the installation page

6

This issue can be resolved by following these steps:

  1. vim /etc/ld.so.conf
  2. /usr/local/lib(add it in .conf)
Pang
  • 9,564
  • 146
  • 81
  • 122
stevenloo
  • 61
  • 1
  • 1
3

This issue can be resolved by following these steps:

sudo make uninstall
sudo make distclean
sudo make clean
./configure --prefix=/usr

This cleans the current installation and installs protobuf at /usr Run ldconfig to update ld.so.cache after making sure that /usr/local/lib is listed in /etc/ld.so.conf. i.e. Edit /etc/ld.so.conf and append /usr/local/lib to it and run ldconfig

Sushantkumar M
  • 337
  • 2
  • 7