【问题标题】:C++ Makefile Error (openGl)C++ Makefile 错误 (openGl)
【发布时间】:2016-02-01 23:41:12
【问题描述】:

我的程序有 5 个文件: main.cpp a.cpp b.cpp a.hpp b.hpp 我得到了一个可以使用的骨架 makefile,但在操作它时我没有那么自信。 当我尝试运行“make”时,出现此错误:

#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.

我不确定如何更改我拥有的这个 Makefile 以便我的程序编译。这是一个图形课程,所以我在这些文件中的一个标题是。

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp a.cpp b.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=test
INCLUDE=a.hpp b.hpp
LIBS =  -L /usr/X11R6/lib/ -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
        $(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)

.cpp.o:
        $(CC) $(CFLAGS) $< -o $(INCLUDE) $@

【问题讨论】:

  • 错误信息不是很清楚吗?
  • 哪部分不清楚?

标签: c++ c++11 compiler-errors makefile


【解决方案1】:

您需要将您从错误消息中获得的提示提供给编译器。从错误消息中;

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.

为了能够编译,您需要将-std=c++11 添加到您的 Makefile 的编译器标志中,如下所示;

CFLAGS = -c -Wall -std=c++11

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2021-04-04
    相关资源
    最近更新 更多