Some Notes of Protocol Buffer C++
Operating System: Ubuntu 14.04
Language: C++
1. Refer to the official guided documentations for the Installation of Protocol Buffer:
Overview: https://developers.google.com/protocol-buffers/docs/overview
Downloads: https://developers.google.com/protocol-buffers/docs/downloads
Protocol Buffer for C++: https://developers.google.com/protocol-buffers/docs/cpptutorial
* It is worth noting that read the README.md file before installing Protocol Buffer.
2. If error appears after using the "make" command as follows, follow the steps given below.
Error Information:
protoc: error while loading shared libraries: libprotobuf.so.9: cannot open shared object file: No such file or directory
protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory
Solution:
make a hard link:
#cd /usr/lib
#sudo ln -s /usr/local/lib/libprotobuf.so.9 libprotobuf.so.9
#sudo ln -s /usr/local/lib/libprotoc.so.9 libprotoc.so.9
#g++ -I /usr/local/include/google/protobuf -L /usr/local/lib main.cpp addressbook.pb.cc -lprotobuf -pthread
* In addition, if we are using C++ 11, add -std=c++11 to the sentence:
#g++ -I /usr/local/include/google/protobuf -L /usr/local/lib main.cpp addressbook.pb.cc -lprotobuf -pthread -std=c++11
References: http://stackoverflow.com/questions/10404027/cant-compile-example-from-google-protocol-buffers
来源:oschina
链接:https://my.oschina.net/u/778799/blog/533942