• [转]protobuf的编译安装


    github地址:https://github.com/google/protobuf支持多种语言,有多个语言的版本,本文采用的是在centos7下编译源码进行安装。

    github上有详细的安装说明:https://github.com/google/protobuf/blob/master/src/README.md

    1、确定centos7上已经安装了下面的软件,或者直接用yum进行更新

    autoconf
    automake
    libtool
    curl (used to download gmock)
    make
    g++
    unzip
    

      

    2、下载源码包,解压,编译安装

    地址:https://github.com/google/protobuf/releases

    选择Source code (tar.gz)下载

    tar -zxvf protobuf-3.1.0.tar.gz -C /usr/local/
    cd protobuf-3.1.0/
    # 如果使用的不是源码,而是release版本 (已经包含gmock和configure脚本),可以略过这一步
    ./autogen.sh
    # 指定安装路径
    ./configure --prefix=/usr/local/protobuf
    #编译
    make
    # 测试,这一步很耗时间
    make check
    make install
    # refresh shared library cache.
    ldconfig
    

      

    注意make check这一步会花费比较多的时间

    3、设置一下环境变量 /etc/profile

    # (动态库搜索路径) 程序加载运行期间查找动态链接库时指定除了系统默认路径之外的其他路径
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib
    # (静态库搜索路径) 程序编译期间查找动态链接库时指定查找共享库的路径
    export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/protobuf/lib
    
    export PATH=$PATH:/usr/local/protobuf/bin
    

    4、查看版本

    protoc --version
    

      之后,对于相同的系统环境,就不需要再编译了,直接将编译好的protobuf(目录:/usr/local/protobuf)分发到其他计算机,设置环境变量即可。

  • 相关阅读:
    法师 南邮NOJ网络赛2083
    法师 南邮NOJ网络赛2083
    法师 南邮NOJ网络赛2083
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    【POJ】3630 Phone List
    【POJ】2503 Babelfish
    【POJ】1451 T9
  • 原文地址:https://www.cnblogs.com/wlzy/p/10890268.html
Copyright © 2020-2023  润新知