Makefile c ++ 11支持 [英] Makefile c++11 support

查看:1086
本文介绍了Makefile c ++ 11支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在C ++中开始了一个小项目。我创建了一个简单的Makefile:

i recently started a small project in C++. I created a simply 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

问题是,当我运行 make 时,我得到这种错误gcc:

错误:'nullptr'未在此范围内声明

我没有任何ides我的Makefile有什么问题,可以有人帮我解决这个问题。我的gcc版本是Debian上的4.7.2

提前感谢

The problem is that when i run make i get this kind of errors form 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. My gcc version is 4.7.2 on Debian
Thanks in advance

推荐答案

为了构建 .o 文件,应使用 CXXFLAGS 设置C ++标志:

Since you are using implicit rules for building the .o files, you should use CXXFLAGS to set the C++ flags:


CXXFLAGS = -std = c ++ 0x

CXXFLAGS =-std=c++0x

-I。 -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

同样 g ++ 。如果您的默认设置不调用g ++,则需要添加

Likewise for g++. If your default settings do not invoke g++, then you need to add


CXX = g ++

CXX = g++

这篇关于Makefile c ++ 11支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆