我有一个用 C 编写的程序,它使用以下库:
#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>
在 Windows 中,为了用 gcc 编译这个程序,你必须使用 -lWs2_32
属性。
如何在 linux 中使用 gcc 编译它?
最佳答案
-lWs2_32
是一个链接器选项,用于指定要链接的库。编译器不使用它。
对于 Linux 下的 gcc,使用套接字函数时无需显式指定库。
关于c - 如何在 linux 中使用 windows sockets 编译程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22019989/