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版本就是按着下边的这个教程来的,
下边正式开始重装教程
https://github.com/google/protobuf/releases
这个可以选择不同版本的protobuf下载,我需要退回2.6.1版本的protobuf,下载好之后解压,会得到一个文件夹protobuf-2.6.1
其实找到README.md,这个文档就是安装教程。
./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.csdn.net/u013498583/article/details/74231058
http://blog.csdn.net/10km/article/details/53023527
https://github.com/google/protobuf/tree/v2.6.1