当前位置:   article > 正文

linux安装protobuf3.6.1编译安装 c++ 及安装时遇到的错误_recipe for target 'all-recursive' failed

recipe for target 'all-recursive' failed

 

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

1 源码下载

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

2 准备工作

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

  1. autoconf
  2. automake
  3. libtool
  4. make
  5. g++
  6. unzip

On Ubuntu/Debian, you can install them with:

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

 

3 安装protobuf

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

  1. ./configure
  2. make
  3. make check
  4. sudo make install
  5. sudo ldconfig # refresh shared library cache.

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

4 环境配置

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

$ sudo vim /etc/profile

添加

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

保存执行

source /etc/profile

5 配置动态库路径

sudo vim /etc/ld.so.conf

追加

/usr/local/protobuf/lib

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

 

ldconfig

 

  1. ./configure -prefix=/usr/local/
  2. sudo make #要编译很久
  3. sudo make check
  4. 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/1009075
推荐阅读
相关标签
  

闽ICP备14008679号