User forums > Help
Winsock in Console Application (undefined reference to `WSAStartup@8')
(1/1)
Bj83:
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;
}
--- End code ---
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)
--- End code ---
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
mandrav:
--- Quote ---I already searched the internet for this problem, nothin found...
--- End quote ---
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...
Bj83:
Thanks... :oops:
Looks like i have made some mistake, thanks again.
It works fine now with the lib :oops:
Navigation
[0] Message Index
Go to full version