【发布时间】:2018-08-12 06:51:54
【问题描述】:
我正在尝试使用InetPtonW:
if(InetPtonW(AF_INET, argv[1], &ThisSenderInfo.sin_addr)<=0) {
return 1;
}
但是我在编译时收到以下消息:
warning: implicit declaration of function 'InetPtonW' [-Wimplicit-function-declaration]
undefined reference to `InetPtonW'
collect2.exe: error: ld returned 1 exit status
我已经阅读了位于here 的文档,并且我已经遵循了所有内容,但仍然无法使其正常工作。
• 我正在使用 MinGW 编译 Ws2_32 库 gcc test.c -o test -lws2_32
• 我已经包含了所需的头文件#include <ws2tcpip.h> 和#include <windows.h>
• 我尝试过使用InetPton,但它返回相同的错误
• 在 Windows 10 上运行
【问题讨论】:
-
此 API 从 Windows Vista 开始可用。确保您的目标是 Windows Vista 或更高版本。有关说明,请参阅Using the Windows Headers。
-
与stackoverflow.com/q/4890753/694576相关,如果不是重复的话。
标签: c windows reference undefined