简体   繁体   English

Makefile C ++ 11支持

[英]Makefile c++11 support

i recently started a small project in C++. 我最近用C ++开始了一个小项目。 I created a simply Makefile: 我创建了一个简单的Makefile:

    CC=g++
    CFLAGS =-std=c++0x -I. -c
    VPATH = src include



    vpath %.c src

    vpath %.h include

    TabooSearch : main.o Task.o TabooList.o
                  $(CC) $(CFLAGS) -o TabooSearch main.o Task.o TabooList.o

The problem is that when i run make i get this kind of errors form gcc: 问题是,当我运行make我会从gcc收到这种错误:
error: 'nullptr' was not declared in this scope
I don't have any ides what is wrong with my Makefile, can someone help me solve this problem. 我没有任何想法,我的Makefile有什么问题,有人可以帮助我解决此问题。 My gcc version is 4.7.2 on Debian 我的gcc版本在Debian上是4.7.2
Thanks in advance 提前致谢

Since you are using implicit rules for building the .o files, you should use CXXFLAGS to set the C++ flags: 由于您使用隐式规则来生成.o文件,因此应使用CXXFLAGS设置C ++标志:

CXXFLAGS =-std=c++0x CXXFLAGS = -std = c ++ 0x

No need for -I. 不需要-I. or -c . -c

I would add a few more flags to get decent errors and warnings: 我还会添加一些标志,以得到体面的错误和警告:

CXXFLAGS := -Wall -Wextra -pedantic-errors -std+c++0x CXXFLAGS:= -Wall -Wextra -pedantic-errors -std + c ++ 0x

Likewise for g++ . 对于g++同样如此。 If your default settings do not invoke g++, then you need to add 如果您的默认设置未调用g ++,则需要添加

CXX = g++ CXX = g ++

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM