mercredi 30 décembre 2015

how do I set compilingflags in a makefile?

I'm used to program in IDEs, but switched to vim and plugins recently. Now I try to write a makefile for a c++ project, but somehow if I run make I always get the error

g++    -c -o *.o createOutput.cpp
In file included from /usr/include/c++/4.8/thread:35:0,
                 from createOutput.cpp:5:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #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.
 #error This file requires compiler and library support for the \
  ^

This is my makefile:

CC = clang++

# compiler flags
CFLAGS = -O3 -Wall -Werror -std=c++11
CFLAGS_SFML = -lsfml-graphics -lsfml-window -lsfml-system

all: program.exe clean

program.exe: *.o
    $(CC) -o program.exe *.o $(CFLAGS) $(CFLAGS_SFML) 

getInput.o: getInput.cpp
    $(CC) -c getInput.cpp $(CFLAGS) 

createOutput.o: createOutput.cpp
    $(CC) -c createOutput.cpp $(CFLAGS) 

main.o: main.cpp
    $(CC) -c main.cpp $(CFLAGS)

.PHONY: clean
clean:
    rm *.o
    @echo clean done

Where is my error? Why is it using g++ instead of clang? And why isn't it using the -std=c++11 parameter? Sorry for the beginner questions, I unfortunately can't find a solution with google.

Aucun commentaire:

Enregistrer un commentaire