官方文档:
Windows Socket编程时,在创建 Socket 时出现问题:
Server.cpp:(.text+0x100): undefined reference to `__imp_getaddrinfo' 如下所示:
解决方法:
选择 Tools -> Compiler Options -> General -> Add the following commands when calling the compiler: 中添加
-lws2_32
重新编译即可。
注: 两条命令之间用一个英文空格隔开。
参考:
https://stackoverflow.com/questions/21022654/undefined-reference-to-imp-getaddrinfo