美文网首页
linux下protobuf下载和安装以及问题解决

linux下protobuf下载和安装以及问题解决

作者: ChanYeol666 | 来源:发表于2020-06-02 09:30 被阅读0次

    1.github下载protobuf: https://github.com/google/protobuf

    2.解压:unzip protobuf-master.zip

    3.转换到protobuf-master文件夹:cd protobuf-master

    4.执行:./autogen.sh

    出错:因为google.com被墙了,虚拟机里无法下载gtest,需要手动下载googletest-release-1.5.0.zip,解压缩后,改名为gtest放在protobuf-master目录下

    googletest下载地址:https://github.com/google/googletest/releases

     解决:unzip googletest-release-1.10.0.zip

    把googletest-release-1.10.0放入protobuf-master/third_party文件夹中,删除原来的googletest,再将googletest-release-1.10.0命名为googletest

    5. 再执行:./autogen.sh

    出错:./autogen.sh: line : autoreconf: command not found(缺少autoconf这个工具安装)

    解决:sudo apt-get install autoconf

        出错:出现apt-get: Package has no installation candidate问题

        解决:sudo apt-get update

            出错:错误为”Failed to fetch 404 Not Found”

            解决:cd /etc/apt

                      sudo vim sources.list

    重新替换为下面的路径:

    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

    6.再执行:sudo apt-get update

    出错:The repository 'http://ppa.launchpad.net/shutter/ppa/ubuntu disco Release' does not have a Release file.

    解决:删除对应文件:sudo apt-add-repository -r ppa:shutter/ppa

    7.再执行:sudo apt-get upgrade

    8.再执行:sudo apt-get install autoconf

    9.再执行: ./autogen.sh

    出错:+ mkdir -p third_party/googletest/m4

              + autoreconf -f -i -Wall,no-obsolete

              configure.ac:109: error: possibly undefined macro: AC_PROG_LIBTOOL

                      If this token and others are legitimate, please use m4_pattern_allow.

                      See the Autoconf documentation.

              autoreconf: /usr/bin/autoconf failed with exit status: 1

    解决:sudo apt-get install libtool

    10.再执行:./autogen.sh

    ./autogen.sh成功

    11.执行:./configure

    ./configure成功

    12.执行:make

    make成功

    13.执行:make check

    出错:

    make check出错

    Making check in .

    make[1]: Entering directory '/home/chanyeol/Downloads/protobuf-master'

    make  check-local

    make[2]: Entering directory '/home/chanyeol/Downloads/protobuf-master'

    Making lib/libgmock.a lib/libgmock_main.a in gmock

    make[3]: Entering directory '/home/chanyeol/Downloads/protobuf-master/third_party/googletest/googletest'

    make[3]: *** No rule to make target 'lib/libgtest.la'. Stop.

    make[3]: Leaving directory '/home/chanyeol/Downloads/protobuf-master/third_party/googletest/googletest'

    make[2]: *** [Makefile:2264: check-local] Error 2

    make[2]: Leaving directory '/home/chanyeol/Downloads/protobuf-master'

    make[1]: *** [Makefile:2127: check-am] Error 2

    make[1]: Leaving directory '/home/chanyeol/Downloads/protobuf-master'

    make: *** [Makefile:1839: check-recursive] Error 1

    暂时找不到解决方法,但是没有影响。

    14.执行:sudo make install

    sudo make install成功

    15.执行:protoc --version

    protoc --version出错

    出错:protoc: error while loading shared libraries: libprotoc.so.23: cannot open shared object file: No such file or directory

    解决方法可参考博客:https://blog.csdn.net/xocoder/article/details/9155901

    解决: cd /etc/ld.so.conf.d

                sudo touch libprotobuf.conf

                sudo vim libprotobuf.conf ,插入内容:/usr/local/lib

                sudo ldconfig

    16.再执行:protoc --version

    安装成功

    相关文章

      网友评论

          本文标题:linux下protobuf下载和安装以及问题解决

          本文链接:https://www.haomeiwen.com/subject/ovrezhtx.html