#include
#include
#include
#pragma comment(lib,"ws2_32.lib")
#define PORT 0x1234
int main()
{
printf("Hello world!\n");
unsigned int n;
n = htons(PORT);
printf("%x\n",n);
return 0;
}
以上是出错的代码。
编译结果为:
E:\codeBlocks\cB_project\cprojects\ntohsTest\main.c|11|undefined reference to `_imp__htons@4'|
这个错误网上说是ws2_32.lib这个库没加,照着加在“设置-》编译器”里了,并没有矫正这个错误,请问各位这个如何解决?
在此谢过!