HELP: How to link with Winsock2 library?

Chris Faylor
Mon Jan 8 15:09:00 GMT 2001

On Mon, Jan 08, 2001 at 12:00:35PM -0800, ece lca wrote:
>  I am a green hand at cygwin programming.
>  I tried to compile a winsock program but I kept get
>linking errors. I reduced the program to the simplest
>form, as below:
>#include <windows.h>
>#include <winsock2.h>
>void main(){
>SOCKET socket;
>When I tried to compile it with
>g++ -o main -lws2_32 main.cpp
>I got error message:
>undefined reference to `closesocket@4'
>Could you help me?  Thank you very much.

g++ -o main main.cpp -lws2_32


Want to unsubscribe from this list?
Check out:

More information about the Cygwin mailing list