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消失,编译通过。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

张欣-男

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

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

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

打赏作者

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

抵扣说明:

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

余额充值