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
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++