Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > newbie question - winsock compile error

Reply
Thread Tools

newbie question - winsock compile error

 
 
Jay
Guest
Posts: n/a
 
      08-08-2003
I am getting following error when trying to compile a sample program:

C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x3:test27.cpp:
undefined reference to `WSAStartup@8'
C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x71):test27.cpp:
undefined reference to `WSACleanup@0'

Here is my code:

// c program
#include <stdio.h>
#include <io.h>
#include <winsock.h>

int main()
{
WORD wVersionRequested = MAKEWORD(1,1);
WSADATA wsaData;
int nRet;

// Initialize WinSock.dll
nRet = WSAStartup(wVersionRequested, &wsaData);
if (nRet)
{
fprintf(stderr,"\nWSAStartup(): %d\n", nRet);
WSACleanup();
return 1;
}
return 0;
}

// END

How can I fix it?

Thanks in advance for any help.
 
Reply With Quote
 
 
 
 
Markus Cserna
Guest
Posts: n/a
 
      08-08-2003
Jay wrote:

> I am getting following error when trying to compile a sample program:
>
> C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x3:test27.cpp:
> undefined reference to `WSAStartup@8'
> C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x71):test27.cpp:
> undefined reference to `WSACleanup@0'


Link ws2_32.lib into your program.

Regards,
Markus
 
Reply With Quote
 
 
 
 
bd
Guest
Posts: n/a
 
      08-08-2003
On Fri, 08 Aug 2003 05:56:56 -0700, Jay wrote:

> I am getting following error when trying to compile a sample program:
>
> C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x3:test27.cpp:
> undefined reference to `WSAStartup@8'
> C:\DOCUME~1\user1\LOCALS~1\Temp\cckJbaaa.o(.text+0 x71):test27.cpp:
> undefined reference to `WSACleanup@0'


Winsock is not defined in the ISO C standard, and is thus off-topic in
comp.lang.c. Try comp.os.ms-windows.programmer.tools.winsock or some other
group with 'winsock' in the name.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't compile with Turbo C 4.5 Winsock Moe C Programming 2 11-13-2011 02:16 PM
Winsock & Winsock 2 spears list Computer Support 3 10-16-2007 03:28 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
winsock/mingw compile problem (undefined reference) Dom C++ 1 08-18-2005 12:05 PM
Error--Winsock & Server Errors Wireless Networking 0 07-09-2004 12:52 AM



Advertisments