How to compile c++11 using make command

Hi all,
When trying to compile the host code using <make> command in MobaXterm terminal. I got this error. I am not sure what to do to fix this error. I need help

In file included from /usr/include/c++/4.8.2/array:35:0,
                     from host/src/host.cpp:16:
    /usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: 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.
     #error This file requires compiler and library support for the \
      ^

The solution is in the message. You are using C++11 and this must be enabled in your compiler. C++11 is a new C++ standard that came out in 2011. So something like this:

gcc -std=c++11 ...

Edit: don’t know your Makefile that you are using. It’s probably in CFLAGS in the Makefile. Do something like append the -std=c++11

...
CFLAGS=[...] -std=c++11
...

My Makefile:



ifeq ($(VERBOSE),1)
ECHO :=
else
ECHO := @
endif

# Where is the Intel(R) FPGA SDK for OpenCL(TM) software?
ifeq ($(wildcard $(INTELFPGAOCLSDKROOT)),)
$(error Set INTELFPGAOCLSDKROOT to the root directory of the Intel(R) FPGA SDK for OpenCL(TM) software installation)
endif
ifeq ($(wildcard $(INTELFPGAOCLSDKROOT)/host/include/CL/opencl.h),)
$(error Set INTELFPGAOCLSDKROOT to the root directory of the Intel(R) FPGA SDK for OpenCL(TM) software installation.)
endif

# OpenCL compile and link flags.
AOCL_COMPILE_CONFIG := $(shell aocl compile-config )
AOCL_LINK_CONFIG := $(shell aocl link-config )

# Compilation flags
ifeq ($(DEBUG),1)
CXXFLAGS += -g
else
CXXFLAGS += -O2
endif

# Compiler
CXX := g++

# Target
TARGET := host
TARGET_DIR := bin

# Directories
INC_DIRS := ../common/inc
LIB_DIRS :=

# Files
INCS := $(wildcard )
SRCS := $(wildcard host/src/*.cpp ../common/src/AOCLUtils/*.cpp)
LIBS := rt pthread

# Make it all!
all : $(TARGET_DIR)/$(TARGET)

# Host executable target.
$(TARGET_DIR)/$(TARGET) : Makefile $(SRCS) $(INCS) $(TARGET_DIR)
        $(ECHO)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC $(foreach D,$(INC_DIRS),-I$D) \
                        $(AOCL_COMPILE_CONFIG) $(SRCS) $(AOCL_LINK_CONFIG) \
                        $(foreach D,$(LIB_DIRS),-L$D) \
                        $(foreach L,$(LIBS),-l$L) \
                        -o $(TARGET_DIR)/$(TARGET)

$(TARGET_DIR) :
        $(ECHO)mkdir $(TARGET_DIR)

# Standard make targets
clean :
        $(ECHO)rm -f $(TARGET_DIR)/$(TARGET)

.PHONY : all clean

My guess it’s here. Do something like:

# Compilation flags
ifeq ($(DEBUG),1)
CXXFLAGS += -g -std=c++11
else
CXXFLAGS += -O2 -std=c++11
endif

Thank you very much this works for me and the error disappeared.