I thought how can I access web pages through a program in c ++? one thing led to the other and I found myself reading about Sockets on the microsoft page Creating a basic Winsock application and initializing Winsock . Well, put all the codes in Dev c ++ but I got this error
main.cpp:(.text+0x24): undefined reference to '__imp_WSAStartup'
The code you used was this:
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")
int main() {
WSADATA wsaData;
int iResult;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
return 0;
}
Search SO in English and I found several questions on this topic. The answers that they offered speak that the #pragma comment(lib, "Ws2_32.lib")
that I place at the beginning of the program is not valid for the compiler gcc but only for visual c ++ and that instead of that I have to add the library manually
through the makefile by placing -L"ws2_32"
however try to put it in some places and the springs kept jumping after each compilation
The IDE that I use is DEV C ++ 5.11 and I'm under windows 8, I would like to know how to add the libraries for that IDE and which library should I add
Thank you very much for your attention. I listen to suggestions