ubuntu 安装protobuf

apt 安装

sudo apt install protobuf-compiler

编译安装

– 方式1

资料链接:ubuntu环境 安装ncnn_ubuntu ncnn_jbyyy、的博客-CSDN博客

git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh

./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache.

查看protobuf版本自动检测
protoc --version


ps1: 上面git clone的方式可以直接下安装包即可,如方式2(这两种方式其实是一样的,仅是下载方式和一点环境配置不一样(环境配置按需要来,其实不用专门配置))

ps2: 这里make check 时可能会报错(如下),但这个问题是可以忽略的。。。
在这里插入图片描述

– 方式2

Ubuntn下安装protobuf和使用详解_小小码农Come on的博客-CSDN博客

① 下载protobuf

sudo wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protobuf-all-3.19.4.tar.gz

② 解压protobuf-all-3.19.4.tar.gz

tar -zxvf protobuf-all-3.19.4.tar.gz

③ 编译安装

cd protobuf-3.19.4
sudo ./autogen.sh
sudo ./configure --prefix=$INSTALL_DIR  #--prefix指定安装目录,一般不需要
sudo make
sudo make check
sudo make install
PS:若不指定--prefix, 默认是安装在/usr/local/bin、/usr/local/lib和/usr/local/include/google/protobuf 中的。

ps2: 若未指定--prefix后,不想配置环境变量,使用时可能会报 找不到 libprotoc.so.30 和 libprotobuf.so.30,需要将其映射到/usr/lib/x86_64-linux-gnu才行,如下:

ln -sf /usr/local/lib/libprotoc.so.30 /usr/lib/x86_64-linux-gnu/libprotoc.so.30

ln -sf /usr/local/lib/libprotobuf.so.30 /usr/lib/x86_64-linux-gnu/libprotobuf.so.30

④ 配置环境变量和动态连接库

  • 更改环境变量:

    vim /etc/profile

    在文件的末尾添加如下的两行: (把bin路径和pkgconfig路径添加到系统PATH)

    export PATH=$PATH:/home/fwq/softs/protobuf/bin (安装路径)

    export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig/

  • 配置动态链接库

    vim /etc/ld.so.conf

    在文件中添加/usr/local/protobuf/lib(注意: 在新行处添加)

    $INSTALL_DIR/lib

更改完成之后ldconfig即可

⑤ 查看是否安装成功

protoc --version

  • 11
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装ProtobufUbuntu上可以按照以下步骤进行: 1. 打开终端,运行以下命令以安装所需的依赖项: ``` sudo apt-get install autoconf automake libtool curl make g++ unzip ``` 2. 克隆Protobuf的源代码,并进入源代码目录: ``` git clone https://github.com/google/protobuf.git cd protobuf ``` 3. 初始化和更新子模块并生成配置文件: ``` git submodule update --init --recursive ./autogen.sh ``` 4. 执行配置命令,生成Makefile: ``` ./configure ``` 5. 使用make命令编译Protobuf: ``` make ``` 6. (可选)运行make check命令进行测试。如果没有克隆子模块,测试可能会失败,但仍然可以继续安装。运行make install命令安装Protobuf: ``` make check sudo make install ``` 以上是在Ubuntu安装Protobuf的一般步骤。根据你的操作系统版本和其他特定条件,可能会有一些差异。如果你遇到任何问题,你可以参考引用提供的链接中详细的问题解决方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [ubuntuprotobuf安装使用(详解)](https://blog.csdn.net/m0_46392035/article/details/124697124)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [在 Ubuntu安装 Protobuf 3 的教程详解](https://download.csdn.net/download/weixin_38672800/12842115)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值