Try adding '-lws2_32' to 'Project Options' > 'Linker Options'. This causes
it to link in the WinSock2 library.
Many people seem to be having this problem with libraries so a small
explanation follows:
Just like when you declare a function, you define it at a later point, the
same has to be done for standard library functions (like connect() for
winsock). The header files you include (in this case 'winsock2.h') only
contain the declarations of the functions, not the definitions. The
definitions are contained in separate source files (.cpp) which are compiled
into library files... here, all winsock source files are compiled into
object files (.o) and bundled into 'libws2_32.a', so you need to link it in
to actually use them.
I hope I was clear.
----- Original Message -----
From: cim
To: dev...@li...
Sent: Tuesday, July 30, 2002 7:00 PM
Subject: [Dev-C++] Problems with "winsock2.h"
Anyone could explain me why for every function included in "winsock2.h"
compiler says "[Linker error] undefined reference to 'FUNCTION_NAME @ INT'"
(for example, for the function "connect" the message is
"[Linker error] undefined reference to `connect @ 12'").
How can i solve this problem?
Thanks, Max
|