Caffeのインストールの問題21_protocバージョン

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であり、それより高いまたは低い場合はエラーが発生することがわかります。

このとき、システムのprotobufのバージョンを確認する必要があります。

コマンドラインからprotoc--versionと入力します

表示:libprotoc 3.5.0

実際、アップグレードのために、protobufバージョンが3.5.0にアップグレードされたため、上記のエラーが発生しました。

解決:

caffeディレクトリで再コンパイルします。

きれいにする

すべて-j4にする

次に、caffe関連のコンテンツをシステムディレクトリにインストールする必要がある場合:

sudo make install

このとき、元のプロジェクトを再度コンパイルすると、エラーが消えてコンパイルに合格します。

おすすめ

転載: blog.csdn.net/sdlypyzq/article/details/108791255