2

In Ubuntu 18.04.02 Server Edition I downloaded from here Protobuf-Releases the protobuf-all-3.10.0.zip and, following the indications here ProtocolBuffersReadme I installed in /usr/local/lib/ the libraries:

(base) marco@pc:/usr/local/lib$ ls -lah | grep "libproto*"
-rw-r--r--  1 root root   14M Oct 25 11:27 libprotobuf-lite.a
-rwxr-xr-x  1 root root  1011 Oct 25 11:27 libprotobuf-lite.la
lrwxrwxrwx  1 root root    26 Oct 25 11:27 libprotobuf-lite.so -> libprotobuf-lite.so.21.0.0
lrwxrwxrwx  1 root root    26 Oct 25 11:27 libprotobuf-lite.so.21 -> libprotobuf-lite.so.21.0.0
-rwxr-xr-x  1 root root  5.3M Oct 25 11:27 libprotobuf-lite.so.21.0.0
-rw-r--r--  1 root root   88M Oct 25 11:27 libprotobuf.a
-rwxr-xr-x  1 root root   976 Oct 25 11:27 libprotobuf.la
lrwxrwxrwx  1 root root    21 Oct 25 11:27 libprotobuf.so -> libprotobuf.so.21.0.0
lrwxrwxrwx  1 root root    21 Oct 25 11:27 libprotobuf.so.21 -> libprotobuf.so.21.0.0
-rwxr-xr-x  1 root root   34M Oct 25 11:27 libprotobuf.so.21.0.0
-rw-r--r--  1 root root  136M Oct 25 11:27 libprotoc.a
-rwxr-xr-x  1 root root   992 Oct 25 11:27 libprotoc.la
lrwxrwxrwx  1 root root    19 Oct 25 11:27 libprotoc.so -> libprotoc.so.21.0.0
lrwxrwxrwx  1 root root    19 Oct 25 11:27 libprotoc.so.21 -> libprotoc.so.21.0.0
-rwxr-xr-x  1 root root   45M Oct 25 11:27 libprotoc.so.21.0.0
(base) marco@pc:/usr/local/lib$ 

Following these indications: https://developers.google.com/protocol-buffers/docs/cpptutorial I tried to compile the protobuffer of the example:

(base) marco@pc:~/protobuf-3.10.0/examples$ protoc -I=/usr/local/include -cpp_out=. 
$SRC_DIR/addressbook.proto
protoc: error while loading shared libraries: libprotoc.so.22: cannot open shared object file: No 
such file or directory

Updates:

1) marco@pc:~$ which protoc
/usr/bin/protoc  

(base) marco@pc:/usr/bin$ ls -lah | grep protoc
-rwxr-xr-x  1 root   root     374K Oct 24 19:41 protoc

(base) marco@pc:/usr/bin$ ldd protoc
    linux-vdso.so.1 (0x00007fffc7fc6000)
    libprotoc.so.22 => not found
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6  
(0x00007f23bfea9000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 
(0x00007f23bfc91000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f23bfa72000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f23bf681000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f23bf2e3000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f23c0436000)

How to solve the problem?

Update2: Thanks to @Botje I discovered to have a second, unkown to me,protoc in /usr/protoc. After having delete it, the second one, which I installed before, "re-emerged" and worked just fine

Marco

user2315094
  • 759
  • 3
  • 16
  • 29
  • 1
    Use `which protoc` to find out which `protoc` you are running, then use `ldd` on it to find out its dependencies. It sounds like you have multiple binaries lying around. – Botje Oct 25 '19 at 12:54
  • @Botje (base) marco@pc:~$ which protoc /usr/bin/protoc – user2315094 Oct 25 '19 at 13:15
  • That is not /usr/local/bin, so how did it get there? Did you install protoc (a newer one, so it seems) from `apt-get`? Pick which one you want to use and uninstall the other one. – Botje Oct 25 '19 at 13:16
  • @Botje I guess as you already said there are multiple protoc, even if libprotoc.so.22 is NOT present in both of them. (I updated my question above with ldd info) – user2315094 Oct 25 '19 at 13:19
  • Do you also have a `/usr/local/bin/protoc`? That should have been installed if you followed the instructions. Run that instead of `protoc`. (And really, either get rid of broken protoc in /usr/bin or fix it!) – Botje Oct 25 '19 at 13:20
  • @Botje to get rid of /usr/local/bin/protoc is sufficient to just delete it? Regarding /usr/local/bin I do now understand why the command 'which protoc' doesn't find any protoc in that path. I followed the instructions here https://github.com/protocolbuffers/protobuf/blob/master/src/README.md – user2315094 Oct 25 '19 at 13:23
  • 1
    Again, you need to either fix the one in /usr/bin and remove the one in /usr/local/bin, or use the one in /usr/local/bin and remove the one in /usr/bin. – Botje Oct 25 '19 at 13:24
  • @Botje Just deleting the /usr/bin/protoc the other one /usr/local/bin/protoc emerged. protoc -I=. --cpp_out=. ./addressbook.proto -> addressbook.pb.cc + addressbook.pb.h . Thank you for your kind, prompt and knowledgeable help – user2315094 Oct 25 '19 at 13:29

0 Answers0