I am using MinGW compiler for creating a Chat Client in C. Whenever i
use any function of winsock2, my program does not compile and it gives
linker Error.
What could be wrong?
I have included winsock2.h in my program.
Here is Error Message
----------------------------------------------------------------------------
Compiler: Default compiler
Building Makefile: "F:\projects\c\chatme\Makefile.win"
Executing make...
make.exe -f "F:\projects\c\chatme\Makefile.win" all
gcc.exe connection.o -o "ChatMe.exe" -L"C:/DevCpp/lib" -mwindows
connection.o(.text+0x32):connection.c: undefined reference to
`gethostbyname@4'
collect2: ld returned 1 exit status
make.exe: *** [ChatMe.exe] Error 1
Execution terminated
------------------------------------------------------------------------------
and my program is
------------------------------------------------------------------------------
#include<winsock2.h>
int main (int argc, char **argv)
{
struct hostent *hostent;
int fd;
struct sockaddr_in sockaddr;
hostent = gethostbyname("scs.msg.yahoo.com");
return 0;
}
Please Help me