Reputation:
I have a program written in C which uses the following libraries:
#ifdef _WIN32
#include <winsock2.h>
#define socklen_t int
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
In Windows, in order to compile this program with gcc, you had to use -lWs2_32
property.
How to compile it using gcc in linux?
Upvotes: 1
Views: 2046
Reputation: 49
-lWs2_32 is a linker option to specify a library to link. The compiler does not use it.
For gcc under Linux there is no need to explicitly specify a library when using socket functions.
Upvotes: -1
Reputation: 635
I think you should statically link the executable and use MinGW. But it's just an assumption. Never tried it.
Upvotes: -1
Reputation: 70981
-lWs2_32
is a linker option to specify a library to link. The compiler does not use it.
For gcc under Linux there is no need to explicitly specify a library when using socket functions.
Upvotes: 3