Qt(创建者)与 WinSocks (ws2_32)
我想在我的 Qt 项目中使用旧的代码片段,该项目使用 WinSocks。
我用 Qt Creator 创建了我的程序,但我不知道如何链接到 ws2_32-Library。我已经将 LIBS += -lws2_32
添加到我的 .pro 中,但什么也没发生。那么我如何链接到这个库呢?
编辑:在哪里可以找到 ws2_32.lib 来包含它?我必须先下载它吗?我知道它带有“Visual Studio”,但我不使用它,也不想使用它。
I want to use an older code-fragment in my Qt-project, which is using WinSocks.
I created my program with Qt Creator and I don't know, how I can link to the ws2_32-Library. I already added LIBS += -lws2_32
to my .pro, but nothing happened. So how can I link to this library?
edit: Where can I find the ws2_32.lib to include it? Do I have to download it first? I know it comes with "Visual Studio", but I don't use it and I don't want to use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,当你知道的时候,它真的很简单。Qt-SDK 附带一个 WinSock2-Library,名为
libws2_32.a
。你唯一需要做的就是要做的就是在你的 .pro 中输入这一行:
这包括您项目中的winsock2-library,您无需执行其他操作。
您可以通过在 .pro 中使用以下行来更简单地完成此操作:
ok, when you know it, it's really simple.The Qt-SDK comes with a WinSock2-Library, called
libws2_32.a
.The only thing you have todo, is to enter this line in your .pro:
this includes the winsock2-library to your project and you have nothing else to do.
You may do this slightly more simply by using this line in your .pro:
您应该使用
.lib
的完整路径或相对路径(取决于您环境中的库路径)。来自 qmake 手册:
You are supposed to use the full or relative path (depends on what library paths you have in your enviroment) to the
.lib
s.From the qmake manual:
您还需要添加标头的路径,以便添加动态库的函数签名。
使用
INCLUDEPATH
变量.pro 文件。You need too to add the path to the headers in order to add the function's signatures of a dynamic library.
Use the
INCLUDEPATH
variable into the .pro file.我在
c:\Program Files\Microsoft SDK\Lib\WS2_32.Lib
中有ws2_32.lib
它带有 平台 SDK。我有一个2003年2月的非常旧的版本,我想,我只在使用VC6.0时需要它,但我认为它也是最新版本。I have
ws2_32.lib
inc:\Program Files\Microsoft SDK\Lib\WS2_32.Lib
it comes with the platform sdk. I have a very old version from Feb 2003 I think, I only needed it when I was using VC6.0, but I assume it is in the latest version too.