linux安装protobuf3.6.1编译安装 c++ 及安装时遇到的错误

 

https://www.jianshu.com/p/83fde1089fea

1 源码下载

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf/
git submodule update --init --recursive
./autogen.sh

2 准备工作

在安装前保证有如下工具,如果没有则自行安装:

autoconf
automake 
libtool   
make  
g++  
unzip

On Ubuntu/Debian, you can install them with:

    $ sudo apt-get install autoconf automake libtool curl make g++ unzip

 

3 安装protobuf

接下来执行如下命令,安装时间有点长,耐心等待(可以写成自动化脚本,就无需一步一步执行):

./configure 
make 
make check 
sudo make install 
sudo ldconfig  # refresh shared library cache.

这时一般来说
libprotobuf库在/usr/local/lib路径下
protoc一般在/usr/local/bin路径下

4 环境配置

下面的环境配置,基于以上两个文件的所在径路,下面命令以本人实际环境配置,具体路径具体更改

$ sudo vim /etc/profile

添加

export PATH=$PATH:/usr/local/bin/
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

保存执行

source /etc/profile

5 配置动态库路径

sudo vim /etc/ld.so.conf

追加

/usr/local/protobuf/lib

然后以root权限更新动态库路径

 

ldconfig

 


./configure -prefix=/usr/local/


sudo make #要编译很久

sudo make check

sudo make install

 

 出错情况一:

configure: error: invalid variable name: `–prefix'

正确格式:把prefix前面的"-"改成“--”

例如:./configure --with-http_stub_status_module "--prefix=/usr/webservice/nginx" --with-pcre=/home/tang/ 下载/pcre-8.20 
 

 出错情况二:

我是sudo make时出错了

v2x@ubuntu:~/Desktop/protoBuf/protobuf-3.6.1$ sudo make
make  all-recursive
make[1]: Entering directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1'
Making all in .
make[2]: Entering directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1'
make[2]: Leaving directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1'
Making all in src
make[2]: Entering directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1/src'
depbase=`echo google/protobuf/stubs/bytestream.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
../-libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..    -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -std=c++11 -DNDEBUG -MT google/protobuf/stubs/bytestream.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/stubs/bytestream.lo google/protobuf/stubs/bytestream.cc &&\
mv -f $depbase.Tpo $depbase.Plo
/bin/bash: line 1: ../-libtool: Permission denied
Makefile:3969: recipe for target 'google/protobuf/stubs/bytestream.lo' failed
make[2]: *** [google/protobuf/stubs/bytestream.lo] Error 126
make[2]: Leaving directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1/src'
Makefile:1537: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/v2x/Desktop/protoBuf/protobuf-3.6.1'
Makefile:1444: recipe for target 'all' failed
 

问题:

python 使用protobuf出错:protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file:No such...

解决方法:linux 敲击命令:export LD_LIBRARY_PATH=/usr/local/lib
 

 

linux系统上编译arm版的protobuf库

https://blog.csdn.net/nicebooks/article/details/17962335

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

aFakeProgramer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值