zoukankan      html  css  js  c++  java
  • Linux下protobuf的编译与安装

    1.下载源码

    首先,从github上下载protobuf的源码,地址:https://github.com/google/protobuf,我选择下载2.5.0版本。

    2.编译protobuf

       将下载的压缩包解压缩

    unzip protobuf-2.5.0.zip

    根目录下没有configure文件,却有一个autogen.sh,原来是因为protobuf的编译方式做了修改,要执行autogen.sh才会生成configure脚本。

    但在执行autogen.sh时出错了,因为google.com被墙了,虚拟机里无法下载gtest,于是手动下载googletest-release-1.5.0.zip,解压缩后,改名为gtest放在protobuf-2.5.0目录下 
    autgen.sh代码片段

     1 # Check that gtest is present.  Usually it is already there since the
     2 # directory is set up as an SVN external.
     3 # 判断是否存在gtest目录
     4 if test ! -e gtest; then
     5   echo "Google Test not present.  Fetching gtest-1.5.0 from the web..."
     6   #如果目录不存在则尝试从google.com下载并解压缩,如果google被墙则下载失败
     7   curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx
     8   #将解压缩后的目录改名为gtest
     9   mv gtest-1.5.0 gtest
    10 fi

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

     解压缩

    1 unzip gtest-1.5.0.zip  
    2 mv gtest-1.5.0 gtest  

    执行protobuf编译

    #执行autogen.sh生成configure
    又是一堆的错误!!! 运行./autogen.sh时(用于产生configure,) 出现错误:

    1 linux-lewph:/home/lewph/Projects/System/build_tslib/tslib # ./autogen.sh
    2 ./autogen.sh: line 4: autoreconf: command not found

     缺少autoconf这个工具安装:

    1 yum install -y  autoconf

     再次运行./autogen.sh问题又来了:

    1 linux-lewph:/home/lewph/Projects/System/build_tslib/tslib # ./autogen.sh
    2 Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
    3 autoreconf: failed to run aclocal: No such file or directory
    1 linux-lewph:/home/lewph/Projects/System/build_tslib/tslib # ./autogen.sh
    2 Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
    3 autoreconf: failed to run aclocal: No such file or directory   有这个文件,推测,问题出现在exec "aclocal"这里,

    用cnf查一下,linux-lewph:/home/lewph/Projects/System/build_tslib/tslib # cnf aclocal

    The program 'aclocal' can be found in following packages:
      * automake [ path: /usr/bin/aclocal, repository: zypp (repo-oss) ]
      * automake [ path: /usr/bin/aclocal, repository: zypp (openSUSE 11.2-0) ]

       安装依赖

    1 yum  install automake

    原来是要用到automake这个工具!安装之!完成以后,再运行./autogen.sh .      问题还有!!!:

    1 linux-lewph:/home/lewph/Projects/System/build_tslib/tslib # ./autogen.sh
    2 configure.ac:25: error: possibly undefined macro: AC_DISABLE_STATIC
    3       If this token and others are legitimate, please use m4_pattern_allow.
    4       See the Autoconf documentation.
    5 configure.ac:26: error: possibly undefined macro: AC_ENABLE_SHARED
    6 configure.ac:27: error: possibly undefined macro: AC_LIBTOOL_DLOPEN
    7 configure.ac:28: error: possibly undefined macro: AC_PROG_LIBTOOL
    8 autoreconf: /usr/bin/autoconf failed with exit status: 1

        这是缺少安装包libtool-1.5.22.tar.gz 安装

    yum install -y libtool

    3.安装protobuf

    1 ./autogen.sh  
    2 ./configure
    1 make
    2 make check
    1 sudo make install

     4.成功

        

  • 相关阅读:
    systemctl
    防火墙firewalld
    k8s 基础概念
    进程
    模板问题
    自动发现
    oracle操作
    aix 10代oracle zabbix2.4.4 日志监控
    paramiko
    test
  • 原文地址:https://www.cnblogs.com/bianqi/p/7229437.html
Copyright © 2011-2022 走看看