Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LNK2001 error with static var. 1

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
BE
Hello guys,

I'm trying to write a network client in VC6.0.
I'm using WSADATA, and socket, and I did put mpr.lib wsock32.lib in the linker dialog under object libraries/modules.
I'm gonna use an array of sockets in my program.
Thats why I made my WSADATA var static in my wrapper class for socket, because I (think I) want to initialize it only once (is this correct?) for the complete program.
I get this error:

Communication.obj : error LNK2001: unresolved external symbol "private: static struct WSAData Communication::wsaDat" (?wsaDat@Communication@@0UWSAData@@A)
Communication.obj : error LNK2001: unresolved external symbol "private: static int Communication::wsaInitialized" (?wsaInitialized@Communication@@0HA)
Debug/Upgrade.exe : fatal error LNK1120: 2 unresolved externals

when I don't set them to static, it works fine.
Any clues ?

thnx!

Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

"Those who say they understand chess, understand nothing"

-- Robert HUBNER
 
it means you must initialize this member before using, for example

class x
{
static int y;
};
//initialize y
int x::y = 1234;

now you may use y anywheer.

Ion Filipski
1c.bmp
 
Darn! I did that but I forgot the x:: before my var.
I can't believe I made such a stupid mistake...
Thnx a lot!

Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

"Those who say they understand chess, understand nothing"

-- Robert HUBNER
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top