文章出處

1、前言

  protobuf是Google提供的結構持久化工具,類型XML,但要比XML更加靈活,效率要高。protobuf當初支持C++、JAVA和Python,后來有了支持C語言的Protobuf-c。關于prorobuf可以參考:https://code.google.com/p/protobuf/https://code.google.com/p/protobuf-c/

2、安裝protobuf-c問題

  今天從google官方網站上面下載了protobuf-c,解壓進行安裝,在執行./configure時候出現錯誤:

錯誤提示:protobuf headers are required.

解決辦法:安裝完整的protobuf,安裝在默認的路徑。下載完整的protobuf安裝,下載地址:https://code.google.com/p/protobuf/downloads/list。網上所示的解決辦法如下所示:

https://code.google.com/p/protobuf-c/issues/detail?id=88

https://code.google.com/p/protobuf-c/issues/detail?id=44

安裝完protobuf后,再在protobuf-c目錄下執行./configure執行成功,但是make時候出現錯誤:

protoc: error while loading shared libraries: libprotoc.so.8: cannot open shared
錯誤原因:
protobuf的默認安裝路徑是/usr/local/lib,而/usr/local/lib 不在Linux體系默認的 LD_LIBRARY_PATH 里,所以就找不到該lib
解決方法:
創建文件 /etc/ld.so.conf.d/libprotobuf.conf 包含內容:

保持退出,然后執行. 輸入命令 sudo ldconfig。ldconfig命令參考:http://hi.baidu.com/linuxlife/item/94a6c096a1e4184af0421569

參考:http://blog.csdn.net/xocoder/article/details/9155901

make成功,make install  成功。

測試程序:寫一個proto,文件命名為:dmessage.proto ,內容如下:

 

用protoc-c編譯生成.h和.c文件如下:protoc-c --c_out=.  dmessage.proto 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()