I have a Makefile for this game I'm making. It looks like this.
CC = g++
CFLAGS = -std=c++11 -w
game: main.o item.o game.o player.o map.o room.o menu.o notebook.o enemy.o
$(CC) $(CFLAGS) -o game main.o item.o game.o player.o map.o room.o menu.o notebook.o enemy.o
mv game ../
I am using the -std=c++11
line in the CFLAGS
line, however, when I run make
, I am told that I need to use C++11 since I am using the #include <random>
line in one of my files. I hadn't noticed the compilation wasn't always using the CFLAGS line when compiling until this.
What do I need to do in order to make the automatic compilation of the object files use the CFLAGS
also?
Specify how to generate your .o files:
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
As @juanchopanza mentions, you should really be using CXX
and CXXFLAGS
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.