mardi 5 avril 2016

makefile for c++11 doesn't work

I am new to makefiles. I created the following makefile:

CC=g++
DEBUG= -g
CFLAGS=-c -Wall -std=c++11 $(DEBUG)

all: hello

hello: ConsoleApplication1.o clock.o communication.o device_manager.o devices.o 
    $(CC) ConsoleApplication1.o clock.o communication.o device_manager.o devices.o 

ConsoleApplication1.o: ConsoleApplication1.cpp
        $(CC) $(CFGLAS) ConsoleApplication1.cpp

clock.o: clock.cpp clock.h
        $(CC) $(CFGLAS) clock.cpp

communication.o: communication.cpp 
        $(CC) $(CFGLAS) communication.cpp

device_manager.o: device_manager.cpp 
        $(CC) $(CFGLAS) device_manager.cpp

devices.o: devices.cpp 
        $(CC) $(CFGLAS) devices.cpp

clean:
    rm -rf *.o hello

I put the makefile in the directory of all the code files and run the command "make" from the command line.

I got many errors like:

ConsoleApplication1.cpp:494:30: error: ‘chrono’ is not a member of ‘std’ mytime::duration_timer_t timer; ^ ConsoleApplication1.cpp:494:30: error: ‘chrono’ is not a member of ‘std’ ConsoleApplication1.cpp:494:55: error: template argument 1 is invalid mytime::duration_timer_t timer; ^ ConsoleApplication1.cpp:494:65: error: invalid type in declaration before ‘;’ token mytime::duration_timer_t timer; ^ ConsoleApplication1.cpp:495:11: error: request for member ‘set_duration’ in ‘timer’, which is of non-class type ‘int’ timer.set_duration(std::chrono::seconds(120)); ^ ConsoleApplication1.cpp:495:29: error: ‘std::chrono’ has not been declared timer.set_duration(std::chrono::seconds(120)); ^ ConsoleApplication1.cpp:496:16: error: request for member ‘start’ in ‘timer’, which is of non-class type ‘int’ for( timer.start(); not(timer.expired()); )

When I compile excactly the same file codes in codeBlocks it compiles, so I guess that I have some mistake in the make file. I have one header file in my project name "general.h" which doesn't have a cpp file. Should I put it also in the makefile?

Aucun commentaire:

Enregistrer un commentaire