2

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

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.

Community
  • 1
  • 1
sonics876
  • 947
  • 2
  • 13
  • 31

3 Answers3

7

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.

Timotei
  • 1,909
  • 2
  • 22
  • 31
  • Hi, I have converted the dnssd.lib file to libdnssd.a, but QT is still complaining about the same error, 'UINT8' does not name a type. – Jerry Aug 13 '14 at 12:12
  • @Jerry Well, that's certainly not a linking problem, but a compilation one :) That means that probably you are not including the proper header(s). – Timotei Aug 25 '14 at 19:34
  • I just downloaded the Bonjour SDK. reimp fails with dnssd.lib from the Bonjour SDK "reimp: dnssd.lib: invalid or corrupt import library" – user2757704 Jul 10 '15 at 17:57
0

Try adding

DEFINES += _WIN32

to your project file.

hmuelner
  • 8,093
  • 1
  • 28
  • 39
0

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

sonics876
  • 947
  • 2
  • 13
  • 31