user16767585
user16767585

Reputation: 73

compiling c++11 using make command

I am trying to compile my code on CPU using MobaXterm terminal and I use make command to compile my code. But many errors appears starting with the ones bellow. I searched online and understand that this is an issue with the compiler. But I am using make not g++. Any suggestion to solve these compilation problems.

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 \
      ^
  

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
  

       
                                 ^

Upvotes: 0

Views: 276

Answers (2)

user16767585
user16767585

Reputation: 73

After many tries and suggestions, I finally find out the solution:

Edit my Makefile as follow:

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

 

Upvotes: 1

nmurgor
nmurgor

Reputation: 477

That's more of a compiler issue and not and issue with make.

  1. Check that the compiler is properly set up for the system you are on.
  2. Also,if the compiler is well set up, check if it is compatible to compile C++11 standard as an older compiler could be the issue.

I think it would also be useful if you: -include What OS you are on -what compiler your are using

Let me know if this is useful.

Upvotes: 0

Related Questions