zoukankan      html  css  js  c++  java
  • 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)分发到其他计算机,设置环境变量即可。

  • 相关阅读:
    Spring学习总结之高级装配
    Spring学习总结之装配bean
    NS2安装过程中环境变量设置的问题(ns-2.35)
    =======================分割线======================================
    java的内存管理机制
    Python之面向对象编程
    Python之列表生成式
    Python之函数的参数
    Git基础级介绍
    第四次作业——个人作业——软件案例分析
  • 原文地址:https://www.cnblogs.com/learn21cn/p/6206206.html
Copyright © 2011-2022 走看看