安装 protobuf

一、下载protobuf

方法一:===> git clone https://github.com/protocolbuffers/protobuf.git

方法二:===> 或者将准备好的压缩包进行拖入
解压
Unzip protobuf1.zip

二、安装(Linux Ubuntu)
(1)安装依赖工具
$ sudo apt-get install autoconf automake libtool curl make g++ unzip libffi-dev -y

(2)进入protobuf文件
cd protobuf/

(3)进行安装检测 并生成自动安装脚本
./autogen.sh
./configure

(4)进行编译C代码
make

(5)进行安装
sudo make install

(6)刷新linux共享库关系
sudo ldconfig

三、测试protobuf编译工具
protoc -h
如果正常输出 相关指令 没有报任何error,为安装成功

四、获取 golang语言的proto包

(1)下载
方法一:===> go get -v -u github.com/golang/protobuf/proto
方法二:===>或者将 github.com-golang-protobuf.zip拖入 进行解压到 $GOPATH/src/github.com/golang

(2)进入到文件夹内进行编译
$ cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go/
$ go build

(3)将生成的 protoc-gen-go可执行文件,放在/bin目录下
$ sudo cp protoc-gen-go /bin/

猜你喜欢

转载自www.cnblogs.com/a208606/p/10949327.html