MingW/codeblocks下 [email protected]报错的解决办法

Dev C++的undefined reference to `__imp_htons’或codeclock的undefined reference to’WSAStartup [email protected]

||=== 生成: Debug in ccc (compiler: GNU GCC Compiler) =|
obj\Debug\main.o||In function [email protected]':| D:\code\ccc\main.cpp|16|undefined reference to[email protected]’|
obj\Debug\main.o||In function main':| D:\code\ccc\main.cpp|28|undefined reference to[email protected]’|
D:\code\ccc\main.cpp|30|undefined reference to [email protected]'| D:\code\ccc\main.cpp|33|undefined reference to[email protected]’|
D:\code\ccc\main.cpp|40|undefined reference to [email protected]'| D:\code\ccc\main.cpp|41|undefined reference to[email protected]’|
D:\code\ccc\main.cpp|43|undefined reference to [email protected]'| D:\code\ccc\main.cpp|49|undefined reference to[email protected]’|
D:\code\ccc\main.cpp|56|undefined reference to [email protected]'| D:\code\ccc\main.cpp|62|undefined reference to[email protected]’|
D:\code\ccc\main.cpp|62|undefined reference to `[email protected]’|
||
= Build 失败了: 11 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

gcc client.cpp -o client -lws2_32最后加上-lws2_32即可

MingW/codeblocks下 [email protected]报错的解决办法