Code::Blocks Forums

User forums => Help => Topic started by: Bj83 on November 10, 2005, 03:48:52 pm

Title: Winsock in Console Application (undefined reference to `WSAStartup@8')
Post by: Bj83 on November 10, 2005, 03:48:52 pm
Hi,

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

I started a simple ConsoleApplication with this text in main.cpp:
Code
#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
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
Title: Re: Winsock in Console Application (undefined reference to `WSAStartup@8')
Post by: mandrav on November 10, 2005, 04:04:39 pm
Quote
I already searched the internet for this problem, nothin found...
Yeah right...clicky (http://www.google.com.gr/search?q=undefined+reference+to+%60WSAStartup%408'&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official)
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...
Title: Re: Winsock in Console Application (undefined reference to `WSAStartup@8')
Post by: Bj83 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: