Reputation: 367
I have write a simple makefile
1 LIBS= -L /usr/local/pgsql/lib
2 INCL= -I /usr/local/pgsql/include -I/home/name/
3
4 pg: pg.o
5 gcc -o pg pg.o $(LIBS) -lpq
6
7 pg.o: pg.c
8 gcc -c $(INCL) $(LIBS) pg.c
Under the folder of name, there are three files: pg.c, timer.c, timer.h but it reports error of could not find timefunctions. what's wrong with my makefile? thanks. The error is
gcc -o pg pg.o -L /usr/local/pgsql/lib -lpq
pg.o: In function `main':
pg.c:(.text+0x91): undefined reference to `createTimer'
pg.c:(.text+0xa1): undefined reference to `startTimer'
pg.c:(.text+0x167): undefined reference to `endTimer'
...
pg.c:(.text+0x214): undefined reference to `displayTimer'
pg.c:(.text+0x220): undefined reference to `destroyTimer'
collect2: error: ld returned 1 exit status
make: *** [pg] Error 1
Upvotes: 0
Views: 184
Reputation: 99094
You haven't given us enough information to be certain, but it might be enough to add timer.o
to the prerequisite list of the pg
rule:
pg: pg.o timer.o
gcc -o pg $^ $(LIBS) -lpq
Upvotes: 1