Hi,
I am trying to create a project of client and server communication using sockets. I have four programs and a Makefile
1) header.h (macros and function prototypes)
2) main.c: where command line arguments are handled and server and client functions are called
3) server.c: server function is defined here
4) client.c: client program is defined here
5) Makefile
Here is my Makefile
Code:
server1: server.o main.o
gcc server.o main.o -o server1
client1: client.o main.o
gcc client.o main.o -o client1
main.o: main.c header.h
gcc -c -Wall main.c
client.o: client.c header.h
gcc -c -Wall client.c
server.o: server.c header.h
gcc -c -Wall server.c
clean:
rm -f *.o
When I do "make", I get the following output:
Code:
gcc -c -Wall server.c
gcc server.o main.o -o server1
main.o:main.c:(.text+0x49d): undefined reference to "_client"
collect2: ld returned 1 exit status
make: *** [server1] Error 1
I don't understand what could be the problem. I tried to google, but without much luck.
If I don't use Makefile, i.e. use main() in both server and client programs and compile them separately and run those programs, everything goes fine....The problem occurs when I use Makefile
Can any one please help me ? Thanks in advance.