Ubuntu16.04重装protobuf2.6.1版本

本文介绍如何从源码重新安装protobuf2.6.1版本,解决因版本不匹配导致的编译错误问题。文章详细记录了安装步骤及过程中可能遇到的问题,如依赖包缺失、gtest获取失败等,并提供了相应的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

重装protobuf2.6.1版本

error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which
之前装cartographer的时候,protobuf的版本升级到了3.4版本,然后最近再搞一些gazebo的仿真,下了一些包,好多编译不过,本着不想破坏cartographer包的完整性的想法,没有想对protobuf降级处理。我现在只是编译一些gazebo的包就开始出错,网上好多在遍历caffe和rcnn等东西的时候也报的同样的错误,也找了好多方法实在不行了,对protobuf重装吧

这里写图片描述

这个是cartographer安装的官方教程

https://google-cartographer.readthedocs.io/en/latest/

VERSION="v3.4.1"

# Build and install proto3.
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -Dprotobuf_BUILD_TESTS=OFF \
  ../cmake
ninja
sudo ninja install

这个是cartographer_ros的官方安装文档

https://google-cartographer-ros.readthedocs.io/en/latest/

src/cartographer/scripts/install_proto3.sh

当时更新protobuf版本就是按着下边的这个教程来的,

下边正式开始重装教程

1.github下载源码

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

这个可以选择不同版本的protobuf下载,我需要退回2.6.1版本的protobuf,下载好之后解压,会得到一个文件夹protobuf-2.6.1其实找到README.md,这个文档就是安装教程。

2.安装

./autogen.sh

执行这个命令,你可能会遇到下边这张图片的情况
这里写图片描述

你可以看一下这个脚本,其中有这么一段

if test ! -e gtest; then
  echo "Google Test not present.  Fetching gtest-1.5.0 from the web..."
  curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx
  mv gtest-1.5.0 gtest
fi

这个网站已经挂掉了,404,在3.4.1版本的protobuf中这个脚本里有这么一段

if test ! -e gmock; then
  echo "Google Mock not present.  Fetching gmock-1.7.0 from the web..."
  curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
  unzip -q release-1.7.0.zip
  rm release-1.7.0.zip
  mv googlemock-release-1.7.0 gmock

  curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
  unzip -q release-1.7.0.zip
  rm release-1.7.0.zip
  mv googletest-release-1.7.0 gmock/gtest
fi

可以看到这个网站已经换到github了,但是我们可以从github下载这个包

https://github.com/google/googletest/tree/release-1.5.0

下载好之后,解压得到googletest-release-1.5.0,把这个文件夹拷贝到protobuf-2.6.1文件夹里边,然后重命名为gtest

然后再执行./autogen.sh这个命令

这里写图片描述

然后你又有可能出现这个错误,这个因为有几个包没装

sudo apt-get install autoconf
sudo apt-get install automake 
sudo apt-get install libtool

确定这几个包装好之后,再次运行./autogen.sh这个命令就正常了,然后会生成一个configure文件,再执行下班的命令,就成了

./configure
make
make check
make install

然后查看一下protobuf的版本

sun@sun  ~  protoc --version
libprotoc 2.6.1

参考文章:

http://blog.youkuaiyun.com/u013498583/article/details/74231058

http://blog.youkuaiyun.com/10km/article/details/53023527

https://github.com/google/protobuf/tree/v2.6.1

如果你想重装Ubuntu 16.04,你可以按照以下步骤进行操作: 1. 准备一个8GB或16GB的U盘作为启动盘。你可以使用ultraiso等工具制作启动盘。请注意,如果你的系统是Windows+Ubuntu双系统,要小心不要影响Windows的启动。 2. 在启动盘中选择Ubuntu 16.04的安装文件,并将其安装到U盘中。 3. 在重启计算机时,进入BIOS设置,将启动顺序设置为从U盘启动。 4. 选择“安装Ubuntu”选项,进入安装界面。 5. 在安装过程中,选择适当的语言和键盘布局。 6. 在分区设置中,选择根目录(/)作为安装启动项的位置。根据你的情况,可能需要选择/dev/sda作为安装位置。 7. 点击“现在安装”开始安装过程。 8. 在安装完成后,重新启动计算机。 这样,你就成功地重装Ubuntu 16.04。请注意,这个过程可能会删除你的旧系统和数据,请提前备份重要文件。 #### 引用[.reference_title] - *1* [双系统安装Ubuntu16.04)(含重装教程)](https://blog.csdn.net/qq_36692645/article/details/99706022)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [记录一下ubuntu16.04重新安装系统遇到的问题(重装系列文章一:重装单独ubuntu系统或者win10+ubuntu18双系统...](https://blog.csdn.net/weixin_43710385/article/details/110404804)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [【2021重装ubuntu16.04系统](https://blog.csdn.net/LemonShy2019/article/details/114949447)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值