【caffe】Debug:/caffe.pb.h:error:#error This file was generated by an newer version of protoc

报错源码——来自于caffe.ph.h

怎么生成caffe.pb.h的

if GOOGLE_PROTOBUF_VERSION < 2004000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
endif
if 2004001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
endif
问题原因

caffe.pb.h这个文件是由较新版本的protoc可执行程序产生的,protoc的版本较新,但是你现在安装的protobuf版本较老。也就是说,现在系统上有多个版本的protobuf。例如protobuf-2.6.1和protobuf-3.0.0你应该统一安装的protobuf版本。
比如:当前的protoc来自anaconda2下的bin,用anaconda安装protobuf,connda install protobuf,它自动安装最新版例如protobuf-3.0.0及相应的include,lib文件。
但是,caffe编译的时候,它是去寻找单独安装protobuf时的include和lib。
而这两种protobuf版本不一样,这就是问题产生原因,单独安装的protobuf与anaconda的版本不一致。

解决办法

一般来说,protobuf的bin,include,lib位于同一个文件夹。那么,你就要使得编译链接在寻找头文件库文件时(Makefile.config中)找的也是跟protoc对应的库文件。


我使用的环境是ubuntu。解决方法如下:

1 去github上下载2.5.0版本的protobuf。

网址如下:https://github.com/google/protobuf/releases/tag/v2.5.0

2 安装。我的protoc文件的最终位置为/usr/local/bin
下面以2.4.1为例。
首先自己设法下载一个源码包:
protobuf-2.4.1.tar.bz2,
假设放到/data目录下 1.安装protobuf
tar jxvf protobuf-2.4.1.tar.bz2
./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache.
3 用which protoc命令找到当前protoc文件的位置。将2.5.0版本的protoc文件拷贝过去,覆盖原本的文件。

protoc --version  可查看当前protoc的版本。

回到caffe的路径下,make clean后重新安装即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yuanCruise

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值