Some Notes of Protocol Buffer C++

非 Y 不嫁゛ 提交于 2019-12-04 15:16:02

                                    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


 3. If error appears during c ompiling the file *.cpp with g++, add the path of the library, and type -lprotobuf at the end.
#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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!