Ufo
Ufo

Reputation: 225

Makefile c++11 support

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

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

Upvotes: 2

Views: 7682

Answers (1)

juanchopanza
juanchopanza

Reputation: 227420

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

CXXFLAGS =-std=c++0x

No need for -I. or -c.

I would add a few more flags to get decent errors and warnings:

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

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

CXX = g++

Upvotes: 5

Related Questions