1. 程式人生 > >Linux protobuf錯誤處理

Linux protobuf錯誤處理

In file included from /usr/include/c++/4.8.2/mutex:35:0,
                 from /usr/local/include/google/protobuf/stubs/mutex.h:33,
                 from /usr/local/include/google/protobuf/stubs/common.h:52,
                 from student.pb.h:9,
                 from test.cpp:5:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: 錯誤:#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /usr/local/include/google/protobuf/stubs/common.h:52:0,
                 from student.pb.h:9,
                 from test.cpp:5:
/usr/local/include/google/protobuf/stubs/mutex.h:58:3: 錯誤:‘mutex’不是名稱空間‘std’中的一個型別名
   std::mutex mu_;
   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在成員函式‘void google::protobuf::internal::WrappedMutex::Lock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:51:17: 錯誤:‘mu_’在此作用域中尚未宣告
   void Lock() { mu_.lock(); }
                 ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在成員函式‘void google::protobuf::internal::WrappedMutex::Unlock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:52:19: 錯誤:‘mu_’在此作用域中尚未宣告
   void Unlock() { mu_.unlock(); }
                   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在全域性域:
/usr/local/include/google/protobuf/stubs/mutex.h:61:7: 錯誤:expected nested-name-specifier before ‘Mutex’
 using Mutex = WrappedMutex;
       ^
/usr/local/include/google/protobuf/stubs/mutex.h:61:7: 錯誤:‘Mutex’未宣告
/usr/local/include/google/protobuf/stubs/mutex.h:61:13: 錯誤:expected ‘;’ before ‘=’ token
 using Mutex = WrappedMutex;
             ^
/usr/local/include/google/protobuf/stubs/mutex.h:61:13: 錯誤:expected unqualified-id before ‘=’ token
/usr/local/include/google/protobuf/stubs/mutex.h:66:28: 錯誤:expected ‘)’ before ‘*’ token
   explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
                            ^
/usr/local/include/google/protobuf/stubs/mutex.h:69:3: 錯誤:‘Mutex’不是一個型別名
   Mutex *const mu_;
   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在解構函式‘google::protobuf::internal::MutexLock::~MutexLock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:67:24: 錯誤:‘class google::protobuf::internal::MutexLock’沒有名為‘mu_’的成員
   ~MutexLock() { this->mu_->Unlock(); }
                        ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在全域性域:
/usr/local/include/google/protobuf/stubs/mutex.h:80:33: 錯誤:expected ‘)’ before ‘*’ token
   explicit MutexLockMaybe(Mutex *mu) :
                                 ^
In file included from /usr/local/include/google/protobuf/arena.h:48:0,
                 from student.pb.h:23,
                 from test.cpp:5:
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
 #pragma GCC visibility push(default)
                                     ^
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected unqualified-id before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected declaration before end of line
In file included from /usr/include/c++/4.8.2/mutex:35:0,
                 from /usr/local/include/google/protobuf/stubs/mutex.h:33,
                 from /usr/local/include/google/protobuf/stubs/common.h:52,
                 from student.pb.h:9,
                 from student.pb.cc:4:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: 錯誤:#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /usr/local/include/google/protobuf/stubs/common.h:52:0,
                 from student.pb.h:9,
                 from student.pb.cc:4:
/usr/local/include/google/protobuf/stubs/mutex.h:58:3: 錯誤:‘mutex’不是名稱空間‘std’中的一個型別名
   std::mutex mu_;
   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在成員函式‘void google::protobuf::internal::WrappedMutex::Lock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:51:17: 錯誤:‘mu_’在此作用域中尚未宣告
   void Lock() { mu_.lock(); }
                 ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在成員函式‘void google::protobuf::internal::WrappedMutex::Unlock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:52:19: 錯誤:‘mu_’在此作用域中尚未宣告
   void Unlock() { mu_.unlock(); }
                   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在全域性域:
/usr/local/include/google/protobuf/stubs/mutex.h:61:7: 錯誤:expected nested-name-specifier before ‘Mutex’
 using Mutex = WrappedMutex;
       ^
/usr/local/include/google/protobuf/stubs/mutex.h:61:7: 錯誤:‘Mutex’未宣告
/usr/local/include/google/protobuf/stubs/mutex.h:61:13: 錯誤:expected ‘;’ before ‘=’ token
 using Mutex = WrappedMutex;
             ^
/usr/local/include/google/protobuf/stubs/mutex.h:61:13: 錯誤:expected unqualified-id before ‘=’ token
/usr/local/include/google/protobuf/stubs/mutex.h:66:28: 錯誤:expected ‘)’ before ‘*’ token
   explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
                            ^
/usr/local/include/google/protobuf/stubs/mutex.h:69:3: 錯誤:‘Mutex’不是一個型別名
   Mutex *const mu_;
   ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在解構函式‘google::protobuf::internal::MutexLock::~MutexLock()’中:
/usr/local/include/google/protobuf/stubs/mutex.h:67:24: 錯誤:‘class google::protobuf::internal::MutexLock’沒有名為‘mu_’的成員
   ~MutexLock() { this->mu_->Unlock(); }
                        ^
/usr/local/include/google/protobuf/stubs/mutex.h: 在全域性域:
/usr/local/include/google/protobuf/stubs/mutex.h:80:33: 錯誤:expected ‘)’ before ‘*’ token
   explicit MutexLockMaybe(Mutex *mu) :
                                 ^
In file included from /usr/local/include/google/protobuf/arena.h:48:0,
                 from student.pb.h:23,
                 from student.pb.cc:4:
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
 #pragma GCC visibility push(default)
                                     ^
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected unqualified-id before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected ‘}’ before end of line
/usr/include/c++/4.8.2/typeinfo:39:37: 錯誤:expected declaration before end of line

 

解決辦法:

g++ -std=c++11  -o protobufTest.out -lprotobuf -lpthread  test.cpp student.pb.cc