0

I'm trying to make a simple socket server, but i don't what i'm doing wrong, here is my code:

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <stdio.h>

#pragma comment(lib, "Ws2_32.lib")

int main() {
    WSADATA wsaData;
    int iResult;
    iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
    if (iResult != 0) {
        printf("WSAStartup failed: %d\n", iResult);
        return 1;
    }
    return 0;
}

i take it from here and here

and the compiler output:

C:\Users\joseh\Documents\proyectos\prueba2\main.o   main.cpp:(.text+0x24): undefined reference to `__imp_WSAStartup'
C:\Users\joseh\Documents\proyectos\prueba2\collect2.exe [Error] ld returned 1 exit status
26      C:\Users\joseh\Documents\proyectos\prueba2\Makefile.win recipe for target 'Project2.exe' failed

if you are wondering, i'm using Dev-c++

Sorry if is a basic question, but i'm not much familiar with c++

TheClonerx
  • 343
  • 2
  • 13

0 Answers0