当前位置: 代码迷 >> 综合 >> Unbuntu 安装Protobuf
  详细解决方案

Unbuntu 安装Protobuf

热度:78   发布时间:2024-01-04 02:43:22.0

下载依赖

sudo apt-get install autoconf automake libtool curl make g++ unzip libffi-dev -y

下载protobuf:

git clone https://github.com/protocolbuffers/protobuf.git//解压
unzip protobuf.zip//安装
cd protobuf
./autogen.sh
./configure
make
make install
sudo ldconfig//测试
protoc -h

如果go语言使用

//获取proto包
go get -v -u github.com/golang/protobuf/proto
go build
go install//安装protoc-gen-go插件
go get -v -u github.com/golang/protobuf/protoc-gen-go
//编译
go build
//生成的可执行文件,放在/bin目录下
cp proto-gen-go /bin

//批处理生成protoecho start...set PROTOC="D:\Program Files (x86)\protoc-3.11.4-win64\bin\protoc.exe"
set TARGET=D:\tmp
set SOURCEPATH="D:\testproto"
for /R %SOURCEPATH% %%f in (*.proto) do ( 
%PROTOC% -I=%SOURCEPATH% --cpp_out=%TARGET% %%f
)pauseecho  complate

  相关解决方案