行不通的方法,浪费时间
编译时出现如下提示:
sf@ubuntu:~/caffe$ g++ -o app ./blob_demo.cpp -I ./include/ -D CPU_ONLY -I ./.build_release/src -L .ildb/ -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.