Hello ever one I have made a main function and two files one header and one c file
main.c
#include "sev.h"
int main(int argc, char *argv[])
{
int sockfd, newsockfd, port_no = 1234, index=0;
struct sockaddr_in serv_addr, cli_addr;
fill_server_address(&serv_addr, port_no);
}
sev.c
#include "sev.h"
void
fill_server_address(struct sockaddr_in *serv_addr, int port_no)
{
serv_addr->sin_family = AF_INET;
serv_addr->sin_port = htons(port-no);
serv_addr->sin_addr.s_addr = INADDR_ANY;
}
sev.h
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void fill_server_address(struct sockaddr_in *serv_addr, int port_no);
but in main I am still getting an error
/tmp/cca5VCjZ.o: In function
main': server-main.c:(.text+0x106):fill_server_address’ collect2: ld returned 1
undefined reference to
exit status
Although I have define the function and included it but still why do I am getting this error Can any one please help me to fix it
thanks
Including the header is not enough. You also need to compile
sev.cand link it into the executable: