0
I am wanting to create a socket in c with the windows api winsock2.h but while trying to compile my code returns me the following error
Undefined referrence to Wsastartup
Undefined referrence to Wsagetlast
Error error: Ld returned 1 Exit status
Winsock startup 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;
}