在 Windows 中将 Bonjour (dns_sd.h) 库添加到 Qt [英] Adding Bonjour (dns_sd.h) library to Qt in Windows

查看:31
本文介绍了在 Windows 中将 Bonjour (dns_sd.h) 库添加到 Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试正确添加 Apple 提供的开源 dns_sd.h 库.我正在编写一个使用 BonjourRegistrar 类的程序,如下所示:链接文本

I've been trying to properly add the open source dns_sd.h library provided by Apple. I am writing a program that uses the BonjourRegistrar class as demonstrated here: link text

我已经在 Mac 环境中编写了我的程序,现在我正在尝试将它移植到 Windows.Bonjour SDK 带有几个类,我很困惑如何正确地将类添加到我的 Qt 项目中.我试过添加行:

I've already written my program on the Mac environment and now I am trying to port it to Windows. The Bonjour SDK comes with several classes, and I am quite confused onto how to correctly add the class to my Qt project. I have tried add the line:

win32:LIBS += c:\dnsssd.lib

在 .pro 文件中没有成功.此外,我尝试将 dns_sd.h 和 dns_sd.c 文件添加到我的项目中,但出现了一些错误,例如:

in the .pro file with no success. Also, I attempted to add the dns_sd.h and dns_sd.c files into my project and got a couple of errors such as:

'UINT8':不命名类型'INT8':不命名类型'UINT16' 未命名类型'INT16' 没有命名类型

'UINT8': does not name a type 'INT8': does not name a type 'UINT16' does not name a type 'INT16' does not name a type

最后,我现在正在尝试修改此链接中 xcimo 所描述的 lib 文件链接文本

Finally, I am now trying to modify the lib file as described by xcimo in this link link text

我不知道我是否使用了正确的命令来正确修改这些文件.

I do not know if I am using the correct command to properly modify these files.

推荐答案

Apple 分发的 .lib 只能在使用 MSVC 编译器编译 Qt 应用程序时使用.

The .lib distributed by Apple can be used only if you are compiling the Qt application with the MSVC compiler.

否则,就像你说的,你需要一个 GCC 兼容的库 (.a).为此,您需要执行以下步骤:

Otherwise, like you said, you need a GCC-compatible library (.a). To do that you need to do the following steps:

  1. 在 .lib 上运行 reimp 工具 [0]:reimp dnssd.lib.将生成文件 DLLStub.obj.
  2. 在 .dll 上运行 gendef 工具 [1]:gendef dnssd.dll.将生成文件 dnssd.def..dll 可以从:C:\Windows\System32(如果您使用的是 32 位)或从 C:\Windows\SysWOW64(对于 64 位版本)获得.
  3. 组装最终的.a:dlltool -k -d dnssd.def -l libdnssd.a.
  4. 将.pro文件中的正确路径添加到新创建的库中:LIBS += -L"/path/to/the/library/file" -ldnssd
  1. Run the reimp tool [0] on the .lib: reimp dnssd.lib. A file DLLStub.obj will be generated.
  2. Run the gendef tool [1] on the .dll: gendef dnssd.dll. A file dnssd.def will be generated. The .dll can be obtained from: C:\Windows\System32 if you are using the 32 bit or from C:\Windows\SysWOW64 for the 64 bit version.
  3. Assemble the final .a: dlltool -k -d dnssd.def -l libdnssd.a.
  4. Add the right path int the .pro file, to the newly created library: LIBS += -L"/path/to/the/library/file" -ldnssd

[0] - http://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/mingw-utils-0.4-1/

[1] - http://sourceforge.net/projects/mingw/files/MinGW/Extension/gendef/gendef-1.0.1346/ - gendef 是 pexports 的更好替代品,因为它可以将 stdcall 类型库从 MSVC 转换为 GCC的,所以你可以得到一个合适的 .def 文件.

[1] - http://sourceforge.net/projects/mingw/files/MinGW/Extension/gendef/gendef-1.0.1346/ - gendef is a better alternative to pexports, because it can convert the stdcall-type libraries from MSVC to the GCC ones, so you can get a proper .def file.

PS:我知道作者已经成功了,但我觉得应该有一些关于如何完成的更详细的说明——信息分散在互联网上.

PS: I know the author got it working, but I felt there should be some more detailed instructions on how to get it done -- the information is scattered around the internet.

这篇关于在 Windows 中将 Bonjour (dns_sd.h) 库添加到 Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆