之前在https://blog.csdn.net/uniqueyyc/article/details/83338889,这个里面已经列出错误并解决了。但是过了些天,想要重新编译时发现又会出错,我猜想可能的原因是在更新系统软件时也更新了protobuf,好像知道原因,但还是很难去解决,现在终于解决了就记录下来,免得下次再次碰到。
之前还有个错误是C++编译版本,我在cmakelists文件中加入了以下代码,也不知道有没有起作用:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
而且重新编译了一下opencv3.4,加入了以下的部分重新编译了
以上操作后,错误提示:
CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:4:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: 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 is
^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from .build_release/src/caffe/proto/caffe.pb.cc:4:0:
.build_release/src/caffe/proto/caffe.pb.h:23:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录
compilation terminated.
Makefile:598: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
解决方案:
思想:
可能问题一:安装了anaconda,在anaconda里面重复安装了protobuf,所以导致冲突,也就是重复执行了
sudo apt-get install libprotobuf-dev
和
conda install libprotobuf
可能问题二:protobuf版本太高,与要求不符合,我之前的是3.6.0
// 查看protobuf版本命令
protoc --version
解决:
//如果安装2.6.1版本
# 移除所有相关protobuf的版本
sudo apt-get remove libprotobuf-dev protobuf-compiler
sudo apt-get remove libprotobuf-lite8 libprotoc8
sudo apt-get remove python-protobuf
sudo pip uninstall protobuf
# anaconda
conda uninstall protobuf
conda uninstall libprotobuf
# 重新安装
sudo apt-get install libprotobuf-dev protobuf-compiler
#if anaconda,不要重复
conda install -c anaconda protobuf=2.6.1
安装3.5.1版本
https://github.com/protocolbuffers/protobuf/releases
在上述网站上找到源码并下载,然后编译
安装具体步骤参照下述网址:https://blog.csdn.net/Changer_sun/article/details/79264326
然后重新编译caffe, make all就没有问题了。还有其他问题参考之前的博客https://blog.csdn.net/uniqueyyc/article/details/83338889
参考地址:https://blog.csdn.net/u013498583/article/details/74231058