I have makefile with two source files namely main.cpp
and game.cpp
. Once I add game.cpp
, I'm getting the following warning
clang++ -framework SDL2 main.o -o game
Undefined symbols for architecture x86_64:
And this is the makefile
CXX = clang++
SDL = -framework SDL2
CXXFLAGS = -Wall -c -std-c++11
LDFLAGS = $(SDL)
TARGET = game
all: $(TARGET)
$(TARGET): main.o game.o
$(CXX) $(LDFLAGS) $< -o $@
main.o: main.cpp
$(CXX) $(CXXFLAGS) $< -o $@
game.o: game.cpp
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm *.o && rm $(TARGET)
I'm using Mac.
You are missing game.o
in the build command, this is because $<
is only the first dependency (see the first line in your warning). Hence the functions in game.o
are undefined.
For more info please refer to gnu.org
EDIT: Updated the link as suggested
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.