Author Topic: Linking winsock  (Read 13966 times)

Schtee

  • Guest
Linking winsock
« on: November 24, 2006, 12:26:10 pm »
Hi there.
I'm trying to make a project using winsock. I've tried to link "libws2_32.a" via: Project -> Build options -> Linker tab. When I go to compile I receive the following error:
File       Message
ld.exe    cannot find -lsw2_32.lib

Any ideas? Thanks a lot.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9599
Re: Linking winsock
« Reply #1 on: November 24, 2006, 12:45:34 pm »
ld.exe    cannot find -lsw2_32.lib
There is no such lib "sw2_32.lib", only "w2_32.lib". ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Schtee

  • Guest
Re: Linking winsock
« Reply #2 on: November 24, 2006, 12:50:05 pm »
Which led to my confusion. I'm only trying to link libws2_32. There's no reference I can find to sw2_32.lib, w2_32.lib or anything else.

**EDIT:** After some poking around I found that I had the wrong library under the - Console Application -> Default profile. My bad, sorry.
« Last Edit: November 24, 2006, 01:28:24 pm by Schtee »

Ecliptic Fate

  • Guest
Re: Linking winsock
« Reply #3 on: December 08, 2006, 12:10:30 pm »
good lord what a pain network programming is to learn.


just thought i would drop a hint here.

ws2_32.lib worked for me using the ms toolkit 2003 by adding it as an external dependency under the project properties.

I first attempted GCC and putting it in the linker tab under build options like it mentions above. got nothing.

I'll be playing with this awhile maybe put up a tut when im done.

Offline joubertdj

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: Linking winsock
« Reply #4 on: December 08, 2006, 01:02:20 pm »
Quote
good lord what a pain network programming is to learn.
  :?

Anyway, although this is not a general programming board, I will try and be brief. Attached is a server client udp example written with winsock (Not winsock2, there is a difference) and should be linked with libwsock32.a
I am using MingW, hence the a.

Hope it helps.

EDIT: PS Not an expert at this. But a very cool way to "poll" for data in the UDP socket is:

Code: [Select]
int udpNetworkStack::pollSocketQue()
{

   timePortDelay.tv_sec = 0;
   timePortDelay.tv_usec = 0;

   select(SocketDescriptor+1,&SocketFileDescriptorSet,NULL,NULL,&timePortDelay);

   if (FD_ISSET(SocketDescriptor,&SocketFileDescriptorSet))
   {
      bytesReceived = recvfrom(SocketDescriptor, ReadPacket, PacketSize, 0, (struct sockaddr*)&ClientInformation.networkInformation, &clientLength);
      //Add all the network packets in the que to the linklist
      return(1);
   }
   return(0);
}

[attachment deleted by admin]
« Last Edit: December 08, 2006, 01:13:27 pm by joubertdj »