Jag har denna Makefile'n:
Kod: Markera allt
CFLAGS= -Wall -lglfw -L/usr/X11R6/lib -lGL -lX11 -lm
OBJS = test.o graphics.o
test: test.o graphics.o
# the order of OBJS and CFLAGS is important
# See "Link order of libraries": "http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html"
g++ -o test ${OBJS} ${CFLAGS}
graphics.o: graphics.cpp
g++ ${CFLAGS} -c graphics.cpp
I test.cpp inkluderar jag graphics.h där jag har deklarationen till initWindow( ... )$ make
g++ -c -o test.o test.cpp
# the order of OBJS and CFLAGS is important
# See "Link order of libraries": "http://www.network-theory.co.uk/docs/gc ... ro_18.html"
g++ -o test test.o -Wall -lglfw -L/usr/X11R6/lib -lGL -lX11 -lm
test.o: In function `main':
test.cpp:(.text+0x96): undefined reference to `initWindow(int, int, int, int, char*)'
collect2: ld returnerade avslutningsstatus 1
make: *** [test] Fel 1
Definitionen ligger i graphics.cpp som borde kompileras före målet test utförs.
Varför utförs inte graphics.o före test?
Och varför syns mina kommentarer?
(Jag har tagit bort alla gamla .o-filer innan jag kör make)
(Använder Ubuntu 7.10)