C++ 如何链接 winsock.lib?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9249886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to link winsock.lib?
提问by Safari
In my C++ class, I use sockets.
在我的 C++ 类中,我使用套接字。
I have some errors when linking because, in my opinion, the library winsock.lib is missing.
链接时我有一些错误,因为在我看来,缺少库 winsock.lib。
I included these:
我包括了这些:
#ifdef WIN32
#include <winsock.h>
typedef int socklen_t;
typedef char raw_type;
#endif
How can I link the library winsock.lib
?
I use Windows XP and Visual Studio 2005.
如何链接库winsock.lib
?我使用 Windows XP 和 Visual Studio 2005。
回答by ciphor
The lib file of winsock is "ws_32.lib" (or "ws2_32.lib"), please make sure you've added it.
winsock 的 lib 文件是“ws_32.lib”(或“ws2_32.lib”),请确保你已经添加了它。
回答by Lol4t0
I am unable to find direct link shows what lib to use, but if you study this, you will find out, that windows sockets 1.1is supported through WSOCK32.DLL
, that mean, possible, that you want WSock32.Lib
, instead of Ws2_32.lib
for windows socket version 2.
我无法找到直接的联系说明了什么lib中使用,但如果你研究这个,你会发现,那Windows套接字1.1支持通过WSOCK32.DLL
影响,这就意味着,可能的话,你想WSock32.Lib
,而不是Ws2_32.lib
为Windows套接字第2版。
WSock32.Lib
is a part of Windows SDK
(I have v6.0A, v7.0A installed, both has this library)
WSock32.Lib
是Windows SDK
(我安装了 v6.0A、v7.0A,都有这个库)