Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX Caffe Compilation Fails With Expected Expression Error

I have been trying to install Caffe on my mac running OSX 10.13.6

I have followed several guides, including the installation guide on the caffe site. I have erased everything and restarted several times. I get the same problem no matter what. When I go to compile everything I am getting this

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 /Users/Name/Documents/Programming/PythonEnv/caffe/build/include/caffe/proto/caffe.pb.cc:4: In file included from /Users/Name/Documents/Programming/PythonEnv/caffe/build/include/caffe/proto/caffe.pb.h:9: /usr/local/include/google/protobuf/stubs/common.h:209:17: error: expected expression OnShutdownRun([](const void* p) { delete static_cast<const T*>(p); }, p); ^ In file included from /Users/Name/Documents/Programming/PythonEnv/caffe/build/include/caffe/proto/caffe.pb.cc:4: In file included from /Users/Name/Documents/Programming/PythonEnv/caffe/build/include/caffe/proto/caffe.pb.h:25: In file included from /usr/local/include/google/protobuf/generated_message_table_driven.h:34: In file included from /usr/local/include/google/protobuf/map.h:49: In file included from /usr/local/include/google/protobuf/map_type_handler.h:35: In file included from /usr/local/include/google/protobuf/wire_format_lite_inl.h:43: /usr/local/include/google/protobuf/message_lite.h:117:3: error: unknown type name 'constexpr' constexpr const T& get() const { return reinterpret_cast<const T&>(union_); }

I have also tried using CMake and run into the same problem. I'm not sure where to go from here. I am not incredibly knowledgable about building processes so I apologize if this is vague and will be happy to provide whatever other information might help fix this.

Thank you!

like image 405
Space Man Soup Avatar asked Jan 27 '23 08:01

Space Man Soup


2 Answers

If compiling with make, change Makefile as follows:

- CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)

+ CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11

like image 74
Milind S. Pandit Avatar answered Feb 05 '23 16:02

Milind S. Pandit


This is the same problem as reported here: https://trac.macports.org/ticket/57093#comment:1

The compiler needs to be using C++11. Try making this change in CMakeLists.txt:

if(UNIX OR APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11") endif()

like image 33
qu1j0t3 Avatar answered Feb 05 '23 16:02

qu1j0t3