# Protoc安装


系统:linux

记住,千万别混乱版本,一般protoc可执行文件在/usr/local/bin//usr/bin/

个人这里使用3.13版本示例,下面两部分命令可以写入shell脚本,记住执行要加sudo

特别提示下,源码安装比较耗时,需要十多分钟。

1.命令行直接安装

sudo apt install protobuf-compiler

版本号与镜像源有关,我的阿里服务器是3.0.0,不过我虚拟机Ubu是3.13.0

2.源码安装

github仓库地址:protocolbuffers/protobuf: Protocol Buffers - Google's data interchange format (github.com)

已转存到gitee上:https://gitee.com/mimo431/protobuf.git

#下载
cd ~/Download/
git clone -b 3.13.x https://gitee.com/mimo431/protobuf.git

#下载第三方库benchmark,googletest
cd protobuf/third_party
git clone https://gitee.com/mimo431/benchmark.git
git clone https://gitee.com/mimo431/googletest.git
cd ~/Download/protobuf

#安装
./autogen.sh
./configure
make -j4
make check
sudo make install
sudo ldconfig # refresh shared library cache.

#验证
whereis protoc
which protoc
protoc --version