1. 问题描述
在编译非原版Caffe的时候,特别是编译到cu文件的时候出现如下的错误(推断可能是NVCC时没加C++11标志):
error: #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.
2. 解决办法
报错是说没有添加C++11的编译标志,那么就应该给它添加对应的标志,这里修改Makefile文件,不光添加CXXFLAGS还需要添加NVCCFLAGS和LINKFLAGS,改动之后的对应条目是这样的:
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