undefined reference to "func" when complied with GCC
Posted
by hotlemontea
on Stack Overflow
See other posts from Stack Overflow
or by hotlemontea
Published on 2010-05-08T18:12:02Z
Indexed on
2010/05/08
18:18 UTC
Read the original article
Hit count: 167
gcc
I implement a link list in two files in linklist.h and linklist.c, and I call some functions defined in linklist.h in main function of main.c. linklist.h is included in both linklist.c and main.c. When I compile this program by GCC with Makefile, the error named "undefined reference to xxx" occurs. I think my Makefile is written correctly as below. So what is the possible reason for this linking error
CC=gcc
CFLAGS= -g -O2
TARGET=target
OBJECTS=main.o linklist.o
TARGET: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET)
clean:
rm target $(OBJECTS)
main.o:linklist.h
linklist.o:linklist.h
© Stack Overflow or respective owner