开发者

Adding Bonjour (dns_sd.h) library to Qt in Windows

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

I've already written my program on the Mac environm开发者_Go百科ent 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

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': does not name a type 'INT8': does not name a type 'UINT16' does not name a type 'INT16' does not name a type

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.


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

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

  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 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: 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.


Try adding

DEFINES += _WIN32

to your project file.


I figured it out, you need to use reimp and dll tool to modify the lib library to a .a

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜