After going through the LWIP documents, I wrote a simple tcp echo server code. To compile it and create an executable I wrote the following Makefile. Now, when I run the command make all, it gives error for each of .c files included in the makefile.
The file structure is as follows:
1. tcp_server.c is the main file where I create the tcp server.
2. It uses the tcp_new(), tcp_bind() etc functions defined in "lwip-1.4.1/src/core/lwip/tcp.c" and "lwip-1.4.1/src/core/lwip/tcp_out.c" and I have given the paths for compilation accordingly.
I am just a beginner in writing makefiles and have written the following file going through the GNU Make documentation.
CC=gcc
CFLAGS= -g -Wall
LWIPDIR=../lwip-1.4.1/src
TARGET=tcp_server
INCLUDES= -I../lwip-1.4.1/src/include -I../STABLE-1_4_0/ports/unix/proj/lib\
-I../STABLE-1_4_0/ports/unix/include -I../lwip-1.4.1/src/include/ipv4
LFLAGS= -L../STABLE-1_4_0/ports/unix/proj/lib/liblwip.so
#LIBS= -llwip
COREFILES=$(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_out.c
VPATH = $(LWIPDIR)/core
OBJS = tcp_server.o tcp.o tcp_out.o
MAIN=tcp_server
all : edit
edit : $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o edit $(OBJS) $(LFLAGS)
tcp_server.o : tcp_server.c tcp.o tcp_out.o
$(CC) $(CFLAGS) $(INCLUDES) -c tcp_server.c $(LFLAGS)
tcp.o : $(LWIPDIR)/core/tcp.c
$(CC) $(CFLAGS) $(INCLUDES) -c $(LWIPDIR)/core/tcp.c $(LFLAGS)
tcp_out.o : $(LWIPDIR)/core/tcp_out.c
$(CC) $(CFLAGS) $(INCLUDES) -c $(LWIPDIR)/core/tcp_out.c $(LFLAGS)
clean :
rm -f *.o
All the files include certain headers defined in "lwip-1.4.1/src/include" and I given the arguments to -I accordingly. However on running make, the output shows "Undefined reference to" all the functions which are defined in the lwip header files. What could be the reason? Where I am going wrong?
Thank you for all the help.