proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc

根据<<深度学习21天实战Caffe>>书中P102页,编写程序 blob_demo.cpp, 并把它放置在caffe目录下,
编译时出现如下提示:

sf@ubuntu:~/caffe$ g++ -o app ./blob_demo.cpp -I ./include/ -D CPU_ONLY -I ./.build_release/src -L . ild b/ -lcaffe
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./blob_demo.cpp:3:
./.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
 #error This file was generated by an older version of protoc which is
  ^
./.build_release/src/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
 #error incompatible with your Protocol Buffer headers.  Please
  ^
./.build_release/src/caffe/proto/caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
 #error regenerate this file with a newer version of protoc.
  ^
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./bd.cpp:3:
./.build_release/src/caffe/proto/caffe.pb.h: In member function ‘void caffe::Datum::clear_data()’:
./.build_release/src/caffe/proto/caffe.pb.h:10766:17: error: ‘kEmptyString’ is not a member of ‘google::protobuf::internal’
   if (data_ != &::google::protobuf::internal::kEmptyString) {


                 ^
省略很多类似出错提示


 根据
/.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
 #error This file was generated by an older version of protoc which is

是否 因为作者百度网盘上下的工具包 与现在从git上下载的caffe源程序不兼容?

后来查资料,参考如下:

Hi guys,
It seems this issue has been wrongly closed while some guys haven't managed to solve the problems with protobuf, protoc, .. So I would like to open this issue and give a thorough solution which would solve most of the problems regarding protobuf during caffe installation;
Here the solution goes:

Make sure you don't have already install protobuf and other similar name files
$ sudo apt-get clean
$ sudo apt-get autoclea
$ sudo apt-get autoremove
$ sudo apt-get remove --purge proto\tab              % remove all the files by pressing tab and finding those file or using *.   注:按tab键,补齐:protobuf-compiler
$ sudo dpkg -P proto\tab                                     注:不用按tab,可以直接写protobuf-compiler,  显示:没有此文件

After these steps you are sure that there is no already protobuf in your machine. you can do some of steps e.g. autoremove to make sure.

make sure you've tried installing:

这一步必须要执行:

sudo apt-get install libprotobuf-dev protobuf-compiler


then download protocol-buffer: https://developers.google.com/protocol-buffers/ for your OS.  可以从csdn上查找下载,google不通。
afterwards extract it in (Ubuntu)

$ tar zxvf protobuf-2.6.1.tar.gz
$ cd protobuf-2.6.1
$ ./configure                          这里改成参考书中的形式:   ./configure  --prefix=/home/sf/local_install/


把/home/sf/local_install/bin/protoc 文件删除,


$ make && make all.


生成新的 /home/sf/local_install/bin/protoc 


再对caffe进行

$ make

$ make test

$ make runtest

就可以把以上的错误解决了。

在执行./app之前,需要在命令提示符下 执行 :


$  export  LD_LIBRARY_PATH=/home/sf/caffe/build/lib:$LD_LIBRARY_PATH

$ ./app


以下是参考帖子中的内容,我的过程中没有出现。


if you during make all for caffe faced with error : error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory
fix it simly by sudo ldconfig.
if make all in caffe directory gives you error during make all, try this:
mkdir build && cd build
and then make all.
In this way, it's rare that you encounter with any error during the installation regarding protobuf.
Hopefully helps.

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值