Caffe安装问题21_protoc version

1 编译错误

➜  caffe git:(zxdev_mac)make
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
/bin/sh: line 0: [: -gt: unary operator expected
/bin/sh: line 0: [: -gt: unary operator expected
CXX src/caffe/data_transformer.cpp
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:17:2: 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: 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: regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.
 ^
.build_release/src/caffe/proto/caffe.pb.h:1027:10: error: unknown type name 'PROTOBUF_CONSTEXPR'
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
         ^
.build_release/src/caffe/proto/caffe.pb.h:1027:29: error: expected member name or ';' after declaration specifiers
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
  ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
.build_release/src/caffe/proto/caffe.pb.h:1049:56: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
                                                       ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1051:64: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
                                                               ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1053:68: error: non-virtual member function marked 'final' hides virtual member function
      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
                                                                   ^
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
/usr/local/include/google/protobuf/message.h:303:10: note: hidden overloaded virtual function 'google::protobuf::Message::InternalSerializeWithCachedSizesToArray' declared here: type mismatch at 1st parameter ('google::protobuf::uint8 *' (aka 'unsigned char *') vs 'bool')
  uint8* InternalSerializeWithCachedSizesToArray(
         ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1141:10: error: unknown type name 'PROTOBUF_CONSTEXPR'
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
         ^
.build_release/src/caffe/proto/caffe.pb.h:1141:29: error: expected member name or ';' after declaration specifiers
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
  ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
.build_release/src/caffe/proto/caffe.pb.h:1163:56: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
                                                       ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1165:64: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
                                                               ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1167:68: error: non-virtual member function marked 'final' hides virtual member function
      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
                                                                   ^
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
/usr/local/include/google/protobuf/message.h:303:10: note: hidden overloaded virtual function 'google::protobuf::Message::InternalSerializeWithCachedSizesToArray' declared here: type mismatch at 1st parameter ('google::protobuf::uint8 *' (aka 'unsigned char *') vs 'bool')
  uint8* InternalSerializeWithCachedSizesToArray(
         ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1349:10: error: unknown type name 'PROTOBUF_CONSTEXPR'
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
         ^
.build_release/src/caffe/proto/caffe.pb.h:1349:29: error: expected member name or ';' after declaration specifiers
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
  ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
.build_release/src/caffe/proto/caffe.pb.h:1371:56: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
                                                       ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1373:64: error: only virtual member functions can be marked 'final'
      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
                                                               ^~~~~~~~~~~~~~
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1375:68: error: non-virtual member function marked 'final' hides virtual member function
      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
                                                                   ^
/usr/local/include/google/protobuf/stubs/port.h:127:24: note: expanded from macro 'PROTOBUF_FINAL'
#define PROTOBUF_FINAL final
                       ^
/usr/local/include/google/protobuf/message.h:303:10: note: hidden overloaded virtual function 'google::protobuf::Message::InternalSerializeWithCachedSizesToArray' declared here: type mismatch at 1st parameter ('google::protobuf::uint8 *' (aka 'unsigned char *') vs 'bool')
  uint8* InternalSerializeWithCachedSizesToArray(
         ^
In file included from src/caffe/data_transformer.cpp:8:
In file included from ./include/caffe/data_transformer.hpp:6:
In file included from ./include/caffe/blob.hpp:9:
.build_release/src/caffe/proto/caffe.pb.h:1462:10: error: unknown type name 'PROTOBUF_CONSTEXPR'
  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [.build_release/src/caffe/data_transformer.o] Error 1

2 解决方法

可以看到这个文件是编译caffe时候生成的,并且它所要求的protobuf版本是2.6.0或2.6.1,高于或低于都会出现error

此时需要查看系统的protobuf的版本是多少:

命令行输入 protoc --version

显示:libprotoc 3.5.0

确实因为某次升级将protobuf的版本升级到了3.5.0,所以产生了上述error。

解决方案:

在caffe目录下重新编译:

make clean

make all -j4

然后如果需要将caffe相关的内容安装到系统目录则:

sudo make install

此时再次编译原来的工程,error消失,编译通过。

猜你喜欢

转载自blog.csdn.net/sdlypyzq/article/details/108791255