关于AF_INET,gcc 和 mingw问题

当把带有AF_INET的程序从linux移植到windows时候会发现,编译不过去,会提示AF_INET未定义,

那是因为在gcc中AF_INET定义在

这个头文件中,

在mingw已经没有这个头文件了,在mingw中AF_INET定义在

这个头文件中。,

一下就ok了

 

getaddrinfo getnameinfo这个两个函数在linux下包含在头文件netdb.h中,在windows中包含在ws2tcpip.h中。

||=== Build: Debug 在 server 中 (编译器: GNU GCC Compiler) ===| D:\学习\计网\TCP\server\main.cpp|6|warning: ignoring #pragma comment [-Wunknown-pragmas]| D:\学习\计网\TCP\server\main.cpp||In function 'int main()':| D:\学习\计网\TCP\server\main.cpp|15|warning: unused variable 'sin_size' [-Wunused-variable]| obj\Debug\main.o||In function `main':| D:\学习\计网\TCP\server\main.cpp|18|undefined reference to `__imp_WSAStartup'| D:\学习\计网\TCP\server\main.cpp|24|undefined reference to `__imp_socket'| D:\学习\计网\TCP\server\main.cpp|26|undefined reference to `__imp_WSACleanup'| D:\学习\计网\TCP\server\main.cpp|34|undefined reference to `__imp_htonl'| D:\学习\计网\TCP\server\main.cpp|35|undefined reference to `__imp_htons'| D:\学习\计网\TCP\server\main.cpp|38|undefined reference to `__imp_bind'| D:\学习\计网\TCP\server\main.cpp|40|undefined reference to `__imp_closesocket'| D:\学习\计网\TCP\server\main.cpp|41|undefined reference to `__imp_WSACleanup'| D:\学习\计网\TCP\server\main.cpp|46|undefined reference to `__imp_listen'| D:\学习\计网\TCP\server\main.cpp|48|undefined reference to `__imp_closesocket'| D:\学习\计网\TCP\server\main.cpp|49|undefined reference to `__imp_WSACleanup'| D:\学习\计网\TCP\server\main.cpp|57|undefined reference to `__imp_accept'| D:\学习\计网\TCP\server\main.cpp|62|undefined reference to `__imp_inet_ntoa'| D:\学习\计网\TCP\server\main.cpp|65|undefined reference to `__imp_recv'| D:\学习\计网\TCP\server\main.cpp|75|undefined reference to `__imp_send'| D:\学习\计网\TCP\server\main.cpp|78|undefined reference to `__imp_closesocket'| ||error: ld returned 1 exit status| ||=== 构建 失败: 17 error(s), 2 warning(s) (0 分, 0 秒) ===| 出现以上问题,如何解决
最新发布
05-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值