C未定义对InetPtonW的引用

Cou*_*ite 6 c windows reference undefined

我正在尝试使用InetPtonW:

if(InetPtonW(AF_INET, argv[1], &ThisSenderInfo.sin_addr)<=0) { 
    return 1; 
}
Run Code Online (Sandbox Code Playgroud)

但是在编译时我收到以下消息:

warning: implicit declaration of function 'InetPtonW' [-Wimplicit-function-declaration]
undefined reference to `InetPtonW'
collect2.exe: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我已经阅读了这里的文档,我已经按照所有内容进行了操作,但仍然无法使用它.

•我正在gcc test.c -o test -lws2_32使用MinGW 编译Ws2_32库

•我已经包含了所需的头文件#include <ws2tcpip.h>#include <windows.h>

•我尝试过使用InetPton但它返回相同的错误

•在Windows 10上运行

小智 0

这是一个链接错误。这就是说,包含库路径,未找到给定的函数。请确保您的 InetPtonW 的 dll 库路径或确保它在您的系统中是否可用。