Author Topic: error in linking wsock32.lib  (Read 9410 times)


  • Guest
error in linking wsock32.lib
« on: November 24, 2009, 08:11:29 am »
I am having problem in win32 GUI project (Code::Blocks 8.02 release).
everything was fine before i started winsock part of it.
As I am targeting very low end systems (windows NT having a minimal RAM), I used windows API's in my project and successfully generated the image. This was the good first part.

Second part :
I need to listen on a local port and based on the data received...write the business logic.
I started a new thread and tried to write my first Winsock program starting with
WSASTARTUP() and built it ....
I received an error stating something about wsock32.lib.
I included wsock32.lib into my project and then I am getting
"cannot find -lWSock32.Lib" error everytime I build it ...
then i removed wsock32.lib and compiled but same story....
I have tried everything...I saw one post from Yannis stating to change paramater to -lwsock32.lib but could not get that menu in my IDE.
As my first program was in C (classroom) and then jumped to c# for a long time ..this linking problem has taken my last 16 hours ...
Please help me a laymans language if you have any answer.

Code snippet of new Thread  :
void Thread (PVOID pvoid)
     volatile  PPARAMS pparams ;
     pparams = (PPARAMS) pvoid ;
    //param struct has a handle to the parent window...
//I wrote the logical flow

     //Start the socket
     //put it in an infinite loop for server
     //everytime data received, send message to parent window
     //handle the custome message to call the appropriate function
     //in case of error call _endthread();
//SendMessage (pparams->hwnd, WM_DATARECEIVED (I want to capture this message in parent), 0, 0) ;

  wVersionRequested = MAKEWORD(2, 2);

    WSAStartup(wVersionRequested, &wsaData);

     //_endthread () ;



  • Guest
Re: error in linking wsock32.lib
« Reply #1 on: November 24, 2009, 09:36:24 am »
I'm assuming you are using MinGW, in which case the WinSock link library is called libwsock32.a and can be found in the lib directory of the MinGW distribution. You can link to it using the the -lwsock32 command line option. Note that this is an older version of WinSocjk - depending on what exactly you are targeting, you should really link with libws2_32.a (which corresponds to ws2_32.lib in MS speak)

« Last Edit: November 24, 2009, 09:39:00 am by zabzonk »