官方文檔:
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