Author Topic: Winsock in Console Application (undefined reference to `WSAStartup@8')  (Read 20099 times)

Bj83

  • Guest
Hi,

I already searched the internet for this problem, nothin found... :?

I started a simple ConsoleApplication with this text in main.cpp:
Code: [Select]
#include <winsock.h>
#include <iostream>

using namespace std;

int main()
{
    WSADATA wsaData;
    if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
    {
        cout<<"WSAStartup failed."<<endl;
    }
return 0;
}

the compiler say:
Code: [Select]
Project   : Console application
Compiler  : GNU GCC Compiler (called directly)
Directory : G:\Dokumente und Einstellungen\ma\Eigene Dateien\Neuer Ordner (6)\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
Linking console executable: G:\Dokumente und Einstellungen\ma\Eigene Dateien\Neuer Ordner (6)\console.exe
.objs\main.o:main.cpp:(.text+0x145): undefined reference to `WSAStartup@8'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)

I just want a simple Winsock App. I read on some sites its a problem with the lib files, but no one could tell how to fix it.

Using Code::Blocks 1RC2 Windows Version; GNU GCC compiler

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Winsock in Console Application (undefined reference to `WSAStartup@8')
« Reply #1 on: November 10, 2005, 04:04:39 pm »
Quote
I already searched the internet for this problem, nothin found...
Yeah right...clicky
Google says: Results 1 - 50 of about 565 English pages for undefined reference to `WSAStartup@8'. (2.46 seconds)

Add libws2_32.a in link libraries...
Be patient!
This bug will be fixed soon...

Bj83

  • Guest
Re: Winsock in Console Application (undefined reference to `WSAStartup@8')
« Reply #2 on: November 10, 2005, 08:06:10 pm »
Thanks...  :oops:
Looks like i have made some mistake, thanks again.

It works fine now with the lib :oops: