The problem is that my webserver works fine when I compile my code in terminal using gcc directly:
gcc webserver.c ../include/webserverinit.c ../include/webserver_request_response.c -o webserver
but after using Makefile the code doesn't work fine. I don't get any error but one of the functions doesn't work correctly
I don't understand what is happening here. I know my code is ok and to make sure the Makefile is working fine, I used some Makefile generator as well but it is still the same.
I know my code is ok and to make sure the Makefile is working fine I used some Makefile generator as well but it is still the same
Makefile that I'm using:
CC=gcc
WEBSERVER_OBJECT=./objects/webserver.o
WEBSERVER_SOURCE=./src/webserver.c
WEBSERVERINIT_OBJECT=./objects/webserverinit.o #Library to start the webserver and listening on the port
WEBSERVERINIT_SOURCE=./include/webserverinit.c
WEBSERVERINIT_HEADER=./include/webserverinit.h
WEBSERVER_REQUEST_RESPONSE_OBJECT=./objects/webserver_request_response.o #Library for receiving requests and sending respons
WEBSERVER_REQUEST_RESPONSE_SOURCE=./include/webserver_request_response.c
WEBSERVER_REQUEST_RESPONSE_HEADER=./include/webserver_request_response.h
OBJECTS=./objects/webserver.o ./objects/webserverinit.o ./objects/webserver_request_response.o #objects folder
HEADERS=./include/webserverinit.h ./include/webserver_request_response.h #headers
OBJECTDIR=./objects
webserver: ${OBJECTS}
${CC} ${OBJECTS} -o webserver
${WEBSERVER_OBJECT}: ${WEBSERVER_SOURCE} ${HEADERS}
${CC} -c ${WEBSERVER_SOURCE} -o ${WEBSERVER_OBJECT}
${WEBSERVERINIT_OBJECT}: ${WEBSERVERINIT_SOURCE} ${WEBSERVERINIT_HEADER}
${CC} -c ${WEBSERVERINIT_SOURCE} -o ${WEBSERVERINIT_OBJECT}
${WEBSERVER_REQUEST_RESPONSE_OBJECT}: ${WEBSERVER_REQUEST_RESPONSE_SOURCE} ${WEBSERVER_REQUEST_RESPONSE_HEADER}
${CC} -c ${WEBSERVER_REQUEST_RESPONSE_SOURCE} -o ${WEBSERVER_REQUEST_RESPONSE_OBJECT}
clean:
rm -rf ${OBJECTDIR}/*.o webserver
I want my code works with Makefile as well but it is not working with Makefile. What should I do?