使用make命令编译c++11



我试图使用MobaXterm终端在CPU上编译我的代码,我使用make命令编译我的代码。但是很多错误都是从下面这些开始的。我在网上搜索并了解到这是编译器的问题。但我用的是make,而不是g++。对于解决这些编译问题有什么建议吗?

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


^

经过多次尝试和建议,我终于找到了解决方案:

编辑我的Makefile如下:

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

这更多是编译器的问题,而不是make的问题。

  1. 检查编译器是否正确设置为您所在的系统。
  2. 此外,如果编译器设置良好,检查它是否兼容编译c++ 11标准,因为旧的编译器可能是问题。

我认为如果你:-包括你的操作系统你在用什么编译器

请告诉我这是否有用。

最新更新