gpt4 book ai didi

ubuntu - 构建 Caffe 时找不到 protoc 错误

转载 作者:行者123 更新时间:2023-12-04 18:49:33 27 4
gpt4 key购买 nike

我正在使用 Ubuntu 16、Python 3、CUDA 10.1 和 Tensorflow 2.3。我在 Caffe github repo 上使用了 git clone,然后做了

cd build
cmake ..
make all
我收到了一堆 protobuf 错误:
~/Downloads/caffe/build$ make clean
~/Downloads/caffe/build$ make all
[ 1%] Running C++/Python protocol buffer compiler on /home/me/Downloads/caffe/src/caffe/proto/caffe.proto
Scanning dependencies of target caffeproto
[ 1%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
In file included from /usr/include/c++/5/atomic:38:0,
from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:115,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
In file included from /home/me/anaconda3/include/google/protobuf/stubs/macros.h:34:0,
from /home/me/anaconda3/include/google/protobuf/stubs/common.h:46,
from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:141,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/port.h:114:2: error: #error "Protobuf requires at least C++11."
#error "Protobuf requires at least C++11."
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:120:7: error: expected nested-name-specifier before ‘ConstStringParam’
using ConstStringParam = const std::string &;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:129:9: error: ‘uint8_t’ does not name a type
typedef uint8_t uint8;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:130:9: error: ‘uint16_t’ does not name a type
typedef uint16_t uint16;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:131:9: error: ‘uint32_t’ does not name a type
typedef uint32_t uint32;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:132:9: error: ‘uint64_t’ does not name a type
typedef uint64_t uint64;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:138:14: error: ‘uint32’ does not name a type
static const uint32 kuint32max = 0xFFFFFFFFu;
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:139:14: error: ‘uint64’ does not name a type
static const uint64 kuint64max = PROTOBUF_ULONGLONG(0xFFFFFFFFFFFFFFFF);
...
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:355:10: error: ‘uint64’ does not name a type
static uint64 ToHost64(uint64 x) { return bswap_64(x); }
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:375:10: error: ‘uint16’ does not name a type
static uint16 Load16(const void *p) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:379:32: error: ‘uint16’ has not been declared
static void Store16(void *p, uint16 v) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:383:10: error: ‘uint32’ does not name a type
static uint32 Load32(const void *p) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:387:32: error: ‘uint32’ has not been declared
static void Store32(void *p, uint32 v) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:391:10: error: ‘uint64’ does not name a type
static uint64 Load64(const void *p) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h:395:32: error: ‘uint64’ has not been declared
static void Store64(void *p, uint64 v) {
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h: In static member function ‘static void google::protobuf::BigEndian::Store16(void*, int)’:
/home/me/anaconda3/include/google/protobuf/stubs/port.h:380:45: error: ‘FromHost16’ was not declared in this scope
GOOGLE_UNALIGNED_STORE16(p, FromHost16(v));
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h: In static member function ‘static void google::protobuf::BigEndian::Store32(void*, int)’:
/home/me/anaconda3/include/google/protobuf/stubs/port.h:388:45: error: ‘FromHost32’ was not declared in this scope
GOOGLE_UNALIGNED_STORE32(p, FromHost32(v));
^
/home/me/anaconda3/include/google/protobuf/stubs/port.h: In static member function ‘static void google::protobuf::BigEndian::Store64(void*, int)’:
/home/me/anaconda3/include/google/protobuf/stubs/port.h:396:45: error: ‘FromHost64’ was not declared in this scope
GOOGLE_UNALIGNED_STORE64(p, FromHost64(v));
^
In file included from /home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:151:0,
from /home/me/anaconda3/include/google/protobuf/stubs/common.h:49,
from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:141,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/hash.h: At global scope:
/home/me/anaconda3/include/google/protobuf/stubs/hash.h:50:31: error: expected template-name before ‘<’ token
struct hash : public std::hash<Key> {};
^
/home/me/anaconda3/include/google/protobuf/stubs/hash.h:50:31: error: expected ‘{’ before ‘<’ token
/home/me/anaconda3/include/google/protobuf/stubs/hash.h:50:31: error: expected unqualified-id before ‘<’ token
In file included from /home/me/anaconda3/include/google/protobuf/stubs/common.h:49:0,
from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:141,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h: In constructor ‘google::protobuf::StringPiece::StringPiece()’:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:211:24: error: ‘nullptr’ was not declared in this scope
StringPiece() : ptr_(nullptr), length_(0) {}
^
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h: In constructor ‘google::protobuf::StringPiece::StringPiece(const char*)’:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:215:16: error: ‘nullptr’ was not declared in this scope
if (str != nullptr) {
^
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h: In member function ‘void google::protobuf::StringPiece::clear()’:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:252:12: error: ‘nullptr’ was not declared in this scope
ptr_ = nullptr;
^
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h: In member function ‘void google::protobuf::StringPiece::set(const char*)’:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:264:16: error: ‘nullptr’ was not declared in this scope
if (str != nullptr)
^
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h: In member function ‘std::__cxx11::string google::protobuf::StringPiece::ToString() const’:
/home/me/anaconda3/include/google/protobuf/stubs/stringpiece.h:311:17: error: ‘nullptr’ was not declared in this scope
if (ptr_ == nullptr) return "";
^
In file included from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:141:0,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/common.h: In function ‘void google::protobuf::internal::StrongReference(const T&)’:
/home/me/anaconda3/include/google/protobuf/stubs/common.h:167:17: error: ‘unused’ does not name a type
auto volatile unused = &var;
^
/home/me/anaconda3/include/google/protobuf/stubs/common.h:168:10: error: ‘unused’ was not declared in this scope
(void)&unused; // Use address to avoid an extra load of "unused".
^
In file included from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:142:0,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/logging.h: In function ‘T* google::protobuf::internal::CheckNotNull(const char*, int, const char*, T*)’:
/home/me/anaconda3/include/google/protobuf/stubs/logging.h:167:14: error: ‘nullptr’ was not declared in this scope
if (val == nullptr) {
^
In file included from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:143:0,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: At global scope:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:354:17: error: ‘uint32’ does not name a type
PROTOBUF_EXPORT uint32 strtou32_adaptor(const char* nptr, char** endptr,
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:364:8: error: ‘uint32’ does not name a type
inline uint32 strtou32(const char *nptr, char **endptr, int base) {
^
In file included from /home/me/anaconda3/include/google/protobuf/stubs/common.h:46:0,
from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:141,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: In function ‘google::protobuf::int64 google::protobuf::strto64(const char*, char**, int)’:
...
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:519:33: error: ‘uint64’ was not declared in this scope
inline char* FastUInt64ToBuffer(uint64 i, char* buffer) {
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:519:43: error: expected primary-expression before ‘char’
inline char* FastUInt64ToBuffer(uint64 i, char* buffer) {
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:594:3: error: ‘uint64’ does not name a type
uint64 value;
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: In constructor ‘google::protobuf::strings::Hex::Hex(Int, google::protobuf::strings::PadSpec)’:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:606:5: error: ‘value’ was not declared in this scope
value = sizeof(v) == 1 ? static_cast<uint8>(v)
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:606:42: error: ‘uint8’ does not name a type
value = sizeof(v) == 1 ? static_cast<uint8>(v)
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:607:42: error: ‘uint16’ does not name a type
: sizeof(v) == 2 ? static_cast<uint16>(v)
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:608:42: error: ‘uint32’ does not name a type
: sizeof(v) == 4 ? static_cast<uint32>(v)
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:609:25: error: ‘uint64’ does not name a type
: static_cast<uint64>(v);
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: In constructor ‘google::protobuf::strings::AlphaNum::AlphaNum(unsigned int)’:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:627:55: error: ‘google::protobuf::FastUInt32ToBufferLeft’ cannot be used as a function
piece_size_(FastUInt32ToBufferLeft(u32, digits) - &digits[0]) {}
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: In constructor ‘google::protobuf::strings::AlphaNum::AlphaNum(long long unsigned int)’:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:633:55: error: ‘google::protobuf::FastUInt64ToBufferLeft’ cannot be used as a function
piece_size_(FastUInt64ToBufferLeft(u64, digits) - &digits[0]) {}
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: In constructor ‘google::protobuf::strings::AlphaNum::AlphaNum(long unsigned int)’:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:643:55: error: ‘google::protobuf::FastUInt64ToBufferLeft’ cannot be used as a function
piece_size_(FastUInt64ToBufferLeft(u64, digits) - &digits[0]) {}
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h: At global scope:
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:790:30: error: ‘uint64’ was not declared in this scope
PROTOBUF_EXPORT string ToHex(uint64 num);
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:864:30: error: ‘google::protobuf::IsValidCodePoint’ declared as an ‘inline’ variable
inline bool IsValidCodePoint(uint32 code_point) {
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:864:30: error: ‘uint32’ was not declared in this scope
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:864:49: error: expected ‘,’ or ‘;’ before ‘{’ token
inline bool IsValidCodePoint(uint32 code_point) {
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:876:38: error: ‘uint32’ was not declared in this scope
PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:876:57: error: expected primary-expression before ‘char’
PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);
^
/home/me/anaconda3/include/google/protobuf/stubs/strutil.h:876:69: error: expression list treated as compound expression in initializer [-fpermissive]
PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);
^
In file included from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23:0,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:189:35: error: ‘uint8’ does not name a type
explicit CodedInputStream(const uint8* buffer, int size);
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:228:27: error: ‘uint32’ has not been declared
bool ReadLittleEndian32(uint32* value);
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:230:27: error: ‘uint64’ has not been declared
bool ReadLittleEndian64(uint64* value);
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:235:16: error: ‘uint8’ does not name a type
static const uint8* ReadLittleEndian32FromArray(const uint8* buffer,
...
error: ‘cur_’ was not declared in this scope
bool Skip(int count) { return impl_.Skip(count, &cur_); }
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h: In member function ‘bool google::protobuf::io::CodedOutputStream::GetDirectBufferPointer(void**, int*)’:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1090:54: error: ‘cur_’ was not declared in this scope
return impl_.GetDirectBufferPointer(data, size, &cur_);
...
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h: In static member function ‘static bool google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic()’:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1235:12: error: ‘default_serialization_deterministic_’ was not declared in this scope
return default_serialization_deterministic_.load(
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1236:16: error: ‘memory_order_relaxed’ is not a member of ‘std’
std::memory_order_relaxed) != 0;
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h: In member function ‘void google::protobuf::io::CodedOutputStream::SetCur(int*)’:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1243:29: error: ‘cur_’ was not declared in this scope
void SetCur(uint8* ptr) { cur_ = ptr; }
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h: In static member function ‘static void google::protobuf::io::CodedOutputStream::SetDefaultSerializationDeterministic()’:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1261:5: error: ‘default_serialization_deterministic_’ was not declared in this scope
default_serialization_deterministic_.store(true, std::memory_order_relaxe
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1261:54: error: ‘memory_order_relaxed’ is not a member of ‘std’
default_serialization_deterministic_.store(true, std::memory_order_relaxe
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h: At global scope:
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1270:44: error: ‘google::protobuf::io::CodedInputStream::ReadVarint32’ declared as an ‘inline’ variable
inline bool CodedInputStream::ReadVarint32(uint32* value) {
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1270:44: error: ‘bool google::protobuf::io::CodedInputStream::ReadVarint32’ is not a static data member of ‘class google::protobuf::io::CodedInputStream’
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1270:44: error: ‘uint32’ was not declared in this scope
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1270:52: error: ‘value’ was not declared in this scope
inline bool CodedInputStream::ReadVarint32(uint32* value) {
^
/home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1270:59: error: expected ‘,’ or ‘;’ before ‘{’ token
inline bool CodedInputStream::ReadVarint32(uint32* value) {
^
In file included from /home/me/anaconda3/include/google/protobuf/io/coded_stream.h:1712:0,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.h:23,
from /home/me/Downloads/caffe/build/include/caffe/proto/caffe.pb.cc:4:
/home/me/anaconda3/include/google/protobuf/port_undef.inc:107:27: error: expected ‘}’ before end of line
/home/me/anaconda3/include/google/protobuf/port_undef.inc:107:27: error: expected ‘}’ before end of line
/home/me/anaconda3/include/google/protobuf/port_undef.inc:107:27: error: expected ‘}’ before end of line
/home/me/anaconda3/include/google/protobuf/port_undef.inc:107:27: error: expected declaration before end of line
src/caffe/CMakeFiles/caffeproto.dir/build.make:74: recipe for target 'src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o' failed
make[2]: *** [src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o] Error 1
CMakeFiles/Makefile2:304: recipe for target 'src/caffe/CMakeFiles/caffeproto.dir/all' failed
make[1]: *** [src/caffe/CMakeFiles/caffeproto.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
我也试过
sudo apt-get remove libprotobuf-dev protofbuf-compiler
sudo apt-get install libprotobuf-dev protofbuf-compiler
接着:
conda uninstall libprotobuf
conda uninstall protobuf
但那些没有帮助。任何人都可以帮忙吗?

最佳答案

如错误消息中所述:您需要在 C++11 模式下运行编译器。尝试以 cmake -DCMAKE_CXX_FLAGS='-std=c++11' .. 运行 CMake .

关于ubuntu - 构建 Caffe 时找不到 protoc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63961170/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com