socket() function used in my code returns -1. Inorder to know more about it example_socket() is added and add headerfile
#include<libexplain/socket.h>
While compiling -lexplain is also added. But i have below error
undefined reference to `explain_socket'
Code:
#include <libexplain/socket.h>
main(){
int sock;
if((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1){
char message[5000];
memset(message,0,5000);
printf("\nSOCKET ERROR\n");
printf("err: socket() failed");
fprintf(stderr, "%s\n", explain_socket(AF_INET, SOCK_DGRAM, 0));
exit(EXIT_FAILURE);
}
}
Please help me to solve this problem.
[update from comment]
Compilation command:
cc xyz.c -lexplain -o xyz