| View previous topic :: View next topic |
| Author |
Message |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Fri Jul 17, 2009 9:00 pm Post subject: Winsock help |
|
|
I've decided to learn winsock programming and I've already got a problem... I'm trying to compile an example code from msdn but I get this error | Code: | | 1>Main.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _main | and I don't know what the error means , I remember I tried winsock before and got the same error. Do I have to include any libraries or anything like that?
Source code: | Code: | #include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
int main()
{
WSADATA wsaData;
int iResult;
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if(iResult != 0)
{
wprintf(L"WSAStartup failed: %d\n", iResult);
return 1;
}
return 0;
} |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Jul 17, 2009 9:03 pm Post subject: |
|
|
#pragma comment (lib, "Ws2_32.lib")
This should fix it.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Jul 17, 2009 9:35 pm Post subject: Re: Winsock help |
|
|
| TraxMate wrote: | | Do I have to include any libraries or anything like that? |
yes, MSDN tells you what you need.
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sat Jul 18, 2009 7:40 am Post subject: |
|
|
Thanks now it compiles . Don't know how I missed the line telling me to link Ws2_32.lib...
|
|
| Back to top |
|
 |
|