I am trying to create a socket in c with windows api winsock2.h but when trying to compile my code it returns me the following error
undefined referrence to WSAStartup
undefined referrence to WSAGetLast
Error: ld returned 1 exit status
winsock boot code
#include<stdio.h>
#include<winsock2.h>
#pragma comment(lib,"ws2_32.lib") //Winsock Library
int main(int argc , char *argv[])
{
WSADATA wsa;
printf("\nInitialising Winsock...");
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
{
printf("Failed. Error Code : %d",WSAGetLastError());
return 1;
}
printf("Initialised.");
return 0;
}