Menu

Using Winsock2.h

2006-01-06
2012-09-26
  • Nobody/Anonymous

    My friend is trying to get the following code to work in Dev-C++, but it returns some form of 'link' error.

    What files are required (and where do I place them) to get the following header working.

    include <winsock2.h>

    Thanks.

     
    • Nobody/Anonymous

      Fixed.

      For future reference, this is how we did it:

      • (Menu) Project -> Projects Options
      • Click the "Parameters" tab
      • Click "Add Library or Object"
      • Browse until you find wsock.lib (for Winsock v1.1) or ws2_32.lib (for Winsock 2).
      • Click "Ok" once done.

      :)

       
    • Nobody/Anonymous

      Getting the "header working" is a little off in concept. Take a moment and check out this link

      http://sourceforge.net/forum/forum.php?thread_id=1036465&forum_id=48211

      (Note you will probably have to click the Re: link on this post to get my link to work correctly - SourceForge is a little messed up now)

      It will help you with headers and libraries.

      Now, I suspect you are going to want to link the library known as ws2_32

      Wayne

       
    • Nobody/Anonymous

      Actually, don't get in the habit of expecting libraries called something.lib to work with MinGW/GCC - libraries for GCC will generally have names like

      libsomething.a

      Wayne

       
    • Nobody/Anonymous

      By the way, it was classy and cool for you to take the time to document your answer.

      Wayne

       
    • Anonymous

      Anonymous - 2006-01-06

      All actually you need to do is add the linker option:

      -lws2_32

      This will look for the file libws2_32.a in the default library paths (the -L options).

      I am not sure where you found ws2_32.lib or wsock.lib, but the naming convention for GNU libraries (or archives) would have them called libwsock.a and libws2_32.a - which is indeed the case with those supplied with Dev-C++ - so what are you using?

      Clifford

       
      • Nobody/Anonymous

        considering that extensions are hiding by default i imagine he saw libws2_32 and just assumed it had a lib extension.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.