歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Ubuntu 下配置protobuf

Ubuntu 下配置protobuf

日期:2017/3/1 13:52:22   编辑:關於Linux


最近想研究protobuf ,嘗試了很多次都沒有成功,我用的是ubuntu,在虛擬機下面的 ,protobuf 也用了很多版本但都沒有成功。最終用的是2.5.0版本才成功,話不多說直接開始

梳理一下配置的流程。

首先得到 protobuf 相應的包文件 ,在終端上輸入如下

wget http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz 

下載完畢後進行解壓

tar zxvf protobuf-2.5.0.tar.gz 

進入到解壓目錄

cd protobuf-2.5.0
進行執行

./configure  

中間可能會出錯,估計是G++沒裝好,因為安裝的時候要進行編譯

安裝G++

apt-get install g++
另外最好把Vim、make 也裝了,不然的後面的就很容易出問題,這些在其他教程上都沒提到過,是個人的一點經驗與大家分享一下

apt-get install vim

apt-get install make

./configure 成功之後,接下來 就如下幾步

make 
make check
make install

安裝完成後在終端下執行

vim ~/.profile

打開配置文件,在該文件中添加

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

然後保存退出,接下來執行

source ~/.profile

是配置文件修改生效,最後執行

protoc --version

查看protobuf版本以測試是否安裝成功

接下來的操作 可以參照如下 鏈接 ,他們寫得非常好

http://hahaya.github.io/2013/08/12/use-protobuf-in-c-plus-plus.html

http://www.ccvita.com/507.html





Copyright © Linux教程網 All Rights Reserved