Answering to myself. I completely skipped the first line of the log. You must specify the -std=c++11 option to c++. A little change on the makefile worked.
Il giorno mercoledì 5 dicembre 2018 14:31:05 UTC+1, Antonio Ken Iannillo ha scritto: > > I compiled and installed protobuf as stated in > https://github.com/protocolbuffers/protobuf/tree/master/src > > protoc --version >>> libprotoc 3.6.1 > > I tried to compile examples folder and I got this: > > pkg-config --cflags protobuf # fails if protobuf is not installed > -pthread -I/usr/local/include > c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config > --cflags --libs protobuf` > In file included from /usr/include/c++/5/mutex:35:0, > from /usr/local/include/google/protobuf/stubs/mutex.h:33, > from /usr/local/include/google/protobuf/stubs/common.h:52 > , > from /usr/local/include/google/protobuf/duration.pb.h:9, > from /usr/local/include/google/protobuf/util/time_util.h: > 45, > from add_person.cc:5: > /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 /usr/local/include/google/protobuf/stubs/common.h:52 > :0, > from /usr/local/include/google/protobuf/duration.pb.h:9, > from /usr/local/include/google/protobuf/util/time_util.h: > 45, > from add_person.cc:5: > /usr/local/include/google/protobuf/stubs/mutex.h:58:8: error: ‘mutex’ in > namespace ‘std’ does not name a type > std::mutex mu_; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In member function ‘void > google::protobuf::internal::WrappedMutex::Lock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:51:17: error: ‘mu_’ was > not declared in this scope > void Lock() { mu_.lock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In member function ‘void > google::protobuf::internal::WrappedMutex::Unlock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:52:19: error: ‘mu_’ was > not declared in this scope > void Unlock() { mu_.unlock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: At global scope: > /usr/local/include/google/protobuf/stubs/mutex.h:61:7: error: expected > nested-name-specifier before ‘Mutex’ > using Mutex = WrappedMutex; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h:66:28: error: expected > ‘)’ before ‘*’ token > explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h:69:3: error: ‘Mutex’ > does not name a type > Mutex *const mu_; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In destructor ‘google:: > protobuf::internal::MutexLock::~MutexLock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:67:24: error: ‘class > google::protobuf::internal::MutexLock’ has no member named ‘mu_’ > ~MutexLock() { this->mu_->Unlock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: At global scope: > /usr/local/include/google/protobuf/stubs/mutex.h:80:33: error: expected > ‘)’ before ‘*’ token > explicit MutexLockMaybe(Mutex *mu) : > ^ > In file included from /usr/local/include/google/protobuf/arena.h:48:0, > from /usr/local/include/google/protobuf/duration.pb.h:23, > from /usr/local/include/google/protobuf/util/time_util.h: > 45, > from add_person.cc:5: > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected unqualified-id before > end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected declaration before end > of line > In file included from /usr/include/c++/5/mutex:35:0, > from /usr/local/include/google/protobuf/stubs/mutex.h:33, > from /usr/local/include/google/protobuf/stubs/common.h:52 > , > from addressbook.pb.h:9, > from addressbook.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 /usr/local/include/google/protobuf/stubs/common.h:52 > :0, > from addressbook.pb.h:9, > from addressbook.pb.cc:4: > /usr/local/include/google/protobuf/stubs/mutex.h:58:8: error: ‘mutex’ in > namespace ‘std’ does not name a type > std::mutex mu_; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In member function ‘void > google::protobuf::internal::WrappedMutex::Lock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:51:17: error: ‘mu_’ was > not declared in this scope > void Lock() { mu_.lock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In member function ‘void > google::protobuf::internal::WrappedMutex::Unlock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:52:19: error: ‘mu_’ was > not declared in this scope > void Unlock() { mu_.unlock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: At global scope: > /usr/local/include/google/protobuf/stubs/mutex.h:61:7: error: expected > nested-name-specifier before ‘Mutex’ > using Mutex = WrappedMutex; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h:66:28: error: expected > ‘)’ before ‘*’ token > explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h:69:3: error: ‘Mutex’ > does not name a type > Mutex *const mu_; > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: In destructor ‘google:: > protobuf::internal::MutexLock::~MutexLock()’: > /usr/local/include/google/protobuf/stubs/mutex.h:67:24: error: ‘class > google::protobuf::internal::MutexLock’ has no member named ‘mu_’ > ~MutexLock() { this->mu_->Unlock(); } > ^ > /usr/local/include/google/protobuf/stubs/mutex.h: At global scope: > /usr/local/include/google/protobuf/stubs/mutex.h:80:33: error: expected > ‘)’ before ‘*’ token > explicit MutexLockMaybe(Mutex *mu) : > ^ > In file included from /usr/local/include/google/protobuf/arena.h:48:0, > from addressbook.pb.h:23, > from addressbook.pb.cc:4: > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected unqualified-id before > end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line > /usr/include/c++/5/typeinfo:39:37: error: expected declaration before end > of line > Makefile:34: recipe for target 'add_person_cpp' failed > make: *** [add_person_cpp] Error 1 > > Any idea? > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
