Space Man Soup
Space Man Soup

Reputation: 53

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!

Upvotes: 4

Views: 1102

Answers (3)

Milind S. Pandit
Milind S. Pandit

Reputation: 91

If compiling with make, change Makefile as follows:

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

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

Upvotes: 5

Liang Wu
Liang Wu

Reputation: 11

You just need to replace the newest version of protobuf with protobuf v3.5.1.

wget https://github.com/protocolbuffers/protobuf/archive/v3.5.1.zip

You need to download to source code, and compile it yourself.

Upvotes: 1

qu1j0t3
qu1j0t3

Reputation: 750

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()

Upvotes: 2

Related Questions