下载protobuf
wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
编译
解压下载的文件
cd protobuf-2.6.1 目录
Configure脚本配置
./configure
安装
make检测
make
环境以及源码等进行检测
make check
sudo安装
sudo make install (需要接着输入密码)
我在执行./configure时出现如下问题
Ubuntu: configure error: C++ preprocessor "/lib/cpp" fails sanity check
解决办法
sudo apt-get install build-essential
检查是否安装成功
protoc --version
如果安装成功,会出现版本号 如
libprotoc 2.6.1
如果有问题,会输出错误内容
抱歉一个错误
protoc: error while loading shared libraries: libprotocbuf.so.9: cannot open shared
错误原因
protobuf的默认安装路径是/usr/local/lib
,而/usr/local/lib
不在ubuntu体系默认的LD_LIBRARY_PATH
里,所以就找不到lib
解决办法
cd /etc/ld.so.conf.d/
vim
/usr/local/lib
在 /etc/ld.so.conf.d/
目录下创建文件bprotobuf.conf
文件,文件内容如下
/usr/local/lib
输入命令
sudo ldconfig
protobuf编译时报错:
protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory
环境变量的问题解决方式;
export LD_LIBRARY_PATH=/usr/local/lib
编译生成golang protoc
protoc --go_out=./go golangtest.proto
注释
protoc --go_out={输出路径} {你的proto文件}
本文由 liberxue 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:2017-08-30 11:19:54