Eclipse c++ 中[Linker error] undefined reference to `WSAStartup@8’的解决办法


出现原因: 在Eclipse中使用MinGW编译器的API,底层调用的是windows系统的API函数,需要链接windows的库。

问题解决:
右键工程->Properties->C/C++ Build->Settings->Tool Settings->MinGW C Linker,在Command line pattern中添加标记​​​-lws2_32​​,再次编译即可!

效果如下图:

Eclipse c++ 中[Linker error] undefined reference to `WSAStartup@8‘的解决办法_右键


ends…