PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
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 .build_release/src/caffe/proto/caffe.pb.h:9,
from .build_release/src/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 /usr/local/include/google/protobuf/stubs/common.h:52:0,
from .build_release/src/caffe/proto/caffe.pb.h:9,
from .build_release/src/caffe/proto/caffe.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 .build_release/src/caffe/proto/caffe.pb.h:23,
from .build_release/src/caffe/proto/caffe.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:588: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: ** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
add 'CXXFLAGs += -std=c++11' in Makefile didn't solve it
I think this issue is related to protobuf, which uses C++ 11 features.
Hello my friend. what did you do to get this to work ? i have encountered the same issue, any help would be much appreciated.
@EmpireofKings Generally there are two options: 1. use up-to-date protobuf, and add -std=c++11 to CXXFAGS in makefile, which could be a bit painful; 2. use protobuf 2.x, which is c++ 98 compatible.
I meet the same problem. Have you fixed it?@yaxinshen
@shallyxxxx
I solved this problem by modifying CMakeList.txt
Orginal
# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()if()
Modify
# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
endif()if()
@manifoldQAQ
Thanks this worked for me. I also had to add it to the NVCCFLAGS in the makefile for it to build the NVCC portion successfully.
And also to LINKFLAGS for using make test.
CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) -std=c++11
LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11
@manifoldQAQ Good job!
@amitfishy Hi, I follow your advice, and remove *.pb, then make it, it works well.
However, when I run ./build/tools/caffe train, it has the error:

How to solve the problem? I find some information about 'this program require a version of protobuf' # 5711, most solutions are to rollback protoc version to 2.6, but we need protoc version3.6, So how to make caffe support protobuf 3.6?
Firstly I followed the standard procedure for building caffe. Also I don't recall saying anything about the .pb files here.
I never came across this error specifically but came across similar things.
First take a look at the protoc version by:
protoc --version
You should see 2.6.1 which is your current protobuf version which you must have installed with apt-get.
You must be using cuda 9 which I believe needs v3.6, you can try installing the google protobuf by source. Following the install instructions will install in the default place which should be different from where your apt-get libraries are stored. Be careful if you try to remove the old libs or upgrade them, they can cause issues while booting.
Once you install by source, make sure it is being picked up correctly by checking with the version command or edit the order of the path variables as I've mentioned above in #3046 .
@amitfishy I have installed protoc version3.6

So I am confused,
When protocol version is 3.6, re-make caffe will cause the error:
"#error This file requires compiler and library support for the ISO C++ 2011 standard."
So I add -std=c++ 11 in makefile and it works well, this can explain caffe is using protoc 3.6.
when I run caffe, it says "this program requires version 3.6 of protocol, but the installed version is 2.6.1", why caffe report the error?
Find the .so and .a libs (probably in /usr/local/lib) for your v3.6 and add them to LD_LIBRARY_PATH and LIBRARY_PATH env variables respectively. Make sure to add them in the beginning like:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH //make sure /usr/local/lib is in start
Probably your makefile was pointing to those directories correctly and during runtime it's finding the other version.
Thank you for your reply @amitfishy,
I have added them in LD_LIBRARY_PATH, but it doesn't work well, I guess your advice 'during runtime it's finding the other version' is right, how caffe find protoc during runtime?
Go explore your file system. Find libprotobuf.a and libprotobuf.so (one set will be 9 and the other will be 15)
For v3.5

For v2.6

Could you please try in the build folder:
ldd caffe | grep proto
And share the output?
I don't understand.

Follow your advice:


The caffe has two protobuf dll.
It might be picking up the first one(v2.5) instead of the second (v3.6).
Try the following if you're still up for it:
make clean
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
sudo ldconfig
make all
make test
make runtest
Below is my another compiled caffe(protoc 2.6):

Try rebuilding it such that it gets linked with the right .so and .a libs. Don't forget the:
sudo ldconfig
After exporting the LD path.
When I export LIBRARY_PATH, it has the error '/etc/profile: 30: bad assignment'.
@amitfishy It works!
I am running 'make runtest'. I will post later.
hahaha

Thank you very much for your help @amitfishy !
Good to hear, the problem was the build was linked with the older libs, while the runtime libs were fine.
In summary, the build was linked with older protoc version, I forget to make clean, and LIBRARY_PATH has no effect.
Now caffe can support protoc version 3.6!
Can you check what
ldd caffe | grep proto
gives you now?
It gives the correct version.

CXX .build_release/src/caffe/proto/caffe.pb.cc
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 .build_release/src/caffe/proto/caffe.pb.h:9,
from .build_release/src/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 /usr/local/include/google/protobuf/stubs/common.h:52:0,
from .build_release/src/caffe/proto/caffe.pb.h:9,
from .build_release/src/caffe/proto/caffe.pb.cc:4:
/usr/local/include/google/protobuf/stubs/mutex.h:70: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:63:43: error: ‘mu_’ was not declared in this scope
void Lock() GOOGLE_PROTOBUF_ACQUIRE() { 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:64:45: error: ‘mu_’ was not declared in this scope
void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); }
^
/usr/local/include/google/protobuf/stubs/mutex.h: At global scope:
/usr/local/include/google/protobuf/stubs/mutex.h:73:7: error: expected nested-name-specifier before ‘Mutex’
using Mutex = WrappedMutex;
^
/usr/local/include/google/protobuf/stubs/mutex.h:78:28: error: expected ‘)’ before ‘’ token
explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
^
/usr/local/include/google/protobuf/stubs/mutex.h:81: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:79: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:92:33: error: expected ‘)’ before ‘’ token
explicit MutexLockMaybe(Mutex mu) :
^
In file included from /usr/local/include/google/protobuf/arena.h:48:0,
from .build_release/src/caffe/proto/caffe.pb.h:23,
from .build_release/src/caffe/proto/caffe.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:588: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: ** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
anybody plz help me
libprotoc 3.6.0
i used both above stated solution
Makefile
CXXFLAGS ......
given by @amitfishy
and solution given by @MINZHIJI CMakeLists.txt
BUT both did not worked for me
PLZ HELP ANYBODY
Check the g++ specified in your makefile.
Try:
man g++ //or put whichever g++ binary is being picked up (/usr/bin/g++)
Scroll down and look whether -std flag has option for c++11. If it doesn't, try changing the g++ compiler version. I'm using:
g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When will this be merged into Caffe??
@soulslicer I guess Caffe is no longer actively maintained. You can either hack with Caffe source code or use Caffe2. If you don't want to use Caffe, then some dirty job has to be done to the Makefile in order to use Protobuf 3.x.
No you dont you just need to add that one word into the cmakelists.
I also encountered this error, and the solutions didn't work for me. How to solve this problem?
make all -j8
NVCC src/caffe/layers/recurrent_layer.cu
NVCC src/caffe/layers/cudnn_lcn_layer.cu
NVCC src/caffe/layers/cudnn_lrn_layer.cu
NVCC src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
NVCC src/caffe/layers/batch_reindex_layer.cu
NVCC src/caffe/layers/mvn_layer.cu
NVCC src/caffe/layers/softmax_loss_layer.cu
NVCC src/caffe/layers/exp_layer.cu
In file included from /usr/include/c++/5/atomic:38:0,
from /usr/local/include/google/protobuf/io/coded_stream.h:113,
from .build_release/src/caffe/proto/caffe.pb.h:23,
from ./include/caffe/util/cudnn.hpp:8,
from ./include/caffe/util/device_alternate.hpp:40,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layers/cudnn_lrn_layer.hpp:6,
from src/caffe/layers/cudnn_lrn_layer.cu: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 \
I also encountered this error, and the solutions didn't work for me. How to solve this problem?
make all -j8
NVCC src/caffe/layers/recurrent_layer.cu
NVCC src/caffe/layers/cudnn_lcn_layer.cu
NVCC src/caffe/layers/cudnn_lrn_layer.cu
NVCC src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
NVCC src/caffe/layers/batch_reindex_layer.cu
NVCC src/caffe/layers/mvn_layer.cu
NVCC src/caffe/layers/softmax_loss_layer.cu
NVCC src/caffe/layers/exp_layer.cu
In file included from /usr/include/c++/5/atomic:38:0,
from /usr/local/include/google/protobuf/io/coded_stream.h:113,
from .build_release/src/caffe/proto/caffe.pb.h:23,
from ./include/caffe/util/cudnn.hpp:8,
from ./include/caffe/util/device_alternate.hpp:40,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layers/cudnn_lrn_layer.hpp:6,
from src/caffe/layers/cudnn_lrn_layer.cu: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 \
I meet the same error(complie NVCC) with you. How do you solve it?
@amitfishy 威武霸气
I use python=3.5 on anaconda .when protobuf =3.6 on anaconda, meeting the same problem. so change the protobuf =3.2 ,it will be OK!
"conda install protobuf = 3.2"
I added below codes in Makefile since this solution did not work for some reason.
https://github.com/BVLC/caffe/issues/6359#issuecomment-396907756
NVCCFLAGS += -std=c++11
CXXFLAGS += -std=c++11
LINKFLAGS += -std=c++11
Most helpful comment
@manifoldQAQ
Thanks this worked for me. I also had to add it to the NVCCFLAGS in the makefile for it to build the NVCC portion successfully.
And also to LINKFLAGS for using
make test.