【问题标题】:compiling c++11 using make command使用 make 命令编译 c++11
【发布时间】:2021-09-15 08:04:10
【问题描述】:

我正在尝试使用 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 \
      ^
  

生成文件:

    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
  

       
                                 ^

【问题讨论】:

  • 首先请edit你的问题显示你的Makefile文件,这样我们就可以看到你为编译器设置了哪些标志和选项。
  • 请显示您的 Makefile 的内容,以便我们可以最好地建议您如何添加必要的编译器标志。另请注意,GCC 4.8.2 是古老的
  • 其次,你应该真正升级你的编译器。 GCC 4.8 ,甚至没有完整的 C++11 支持。
  • 为什么不能在选项中添加-std=c++11 or -std=gnu++11
  • 再吹毛求疵:你正在通过你的makefile使用g++

标签: c++ c++11 makefile opencl


【解决方案1】:

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

如下编辑我的Makefile

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

 

【讨论】:

    【解决方案2】:

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

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

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

    让我知道这是否有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-30
      • 1970-01-01
      • 2018-04-21
      相关资源
      最近更新 更多