#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
I m trying to compile my C code for windows from linux since I wrote the code using these header files in linux. Since, compiling in linux had no errors, but I wanted to compile for windows.
I used winsock.h,winsock2.h,windows.h but still while compiling in windows, I m getting these errors:
PS C:\Users\Dell\Downloads\ChatChamber> cd "c:\Users\Dell\Downloads\ChatChamber" ; if ($?) { gcc client.c -o client -lpthread
} ; if ($?) { .\client }
In file included from client.c:14:
C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/i686-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
#warning Please include winsock2.h before windows.h
^~~
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0xd5): undefined reference to _imp__recv@16'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x1bd): undefined reference to _impsend@16'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x2be): undefined reference to `_impsocket@12'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x33e): undefined reference to _imp__inet_addr@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x352): undefined reference to _imphtons@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x377): undefined reference to `_impconnect@12'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x3ba): undefined reference to _imp__getsockname@12'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x3dc): undefined reference to _impgetpeername@12'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x3f0): undefined reference to `_impntohs@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x403): undefined reference to _imp__inet_ntoa@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x42b): undefined reference to _impntohs@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x43e): undefined reference to `_impinet_ntoa@4'
C:\Users\Dell\AppData\Local\Temp\ccnULxsd.o:client.c:(.text+0x47c): undefined reference to `_imp__send@16'
collect2.exe: error: ld returned 1 exit status