ubuntu下配置protobuf

http://blog.csdn.net/guoyilongedu/article/details/17093811


最近想研究protobuf ,尝试了很多次都没有成功,我用的是ubuntu,在虚拟机下面的 ,protobuf 也用了很多版本但都没有成功。最终用的是2.5.0版本才成功,话不多说直接开始

梳理一下配置的流程。


首先得到  protobuf 相应的包文件 ,在终端上输入如下


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

下载完毕后进行解压 
  1. tar zxvf protobuf-2.5.0.tar.gz   

进入到解压目录 


  1. cd protobuf-2.5.0  

进行执行
  1. ./configure    


中间可能会出错,估计是G++没装好,因为安装的时候要进行编译

安装G++    


  1. apt-get install g++  

另外最好把Vim、make 也装了,不然的后面的就很容易出问题,这些在其他教程上都没提到过,是个人的一点经验与大家分享一下
  1. apt-get install vim  


  1. apt-get install make  


./configure 成功之后,接下来 就如下几步
  1. make   
  2. make check  
  3. make install  


安装完成后在终端下执行


  1. vim ~/.profile  


打开配置文件,在该文件中添加


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


然后保存退出,接下来执行


  1. source ~/.profile  

 是配置文件修改生效,最后执行


  1. protoc --version  

查看protobuf版本以测试是否安装成功


接下来的操作 可以参照如下 链接 ,他们写得非常好 





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




http://www.ccvita.com/507.html
原文地址:https://www.cnblogs.com/i80386/p/3555458.html