1 Compilation error
➜ 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 Solution
You can see that this file was generated when caffe was compiled, and the required protobuf version is 2.6.0 or 2.6.1, and errors will occur if it is higher or lower
At this time, you need to check the version of the system's protobuf:
Enter protoc --version from the command line
Display: libprotoc 3.5.0
Indeed, because of an upgrade, the protobuf version was upgraded to 3.5.0, so the above error occurred.
solution:
Recompile in the caffe directory:
make clean
make all -j4
Then if you need to install caffe-related content to the system directory:
sudo make install
At this time, compile the original project again, the error disappears and the compilation passes.