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

后端 未结 3 1322
粉色の甜心
粉色の甜心 2021-01-16 10:02

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

相关标签:
3条回答
  • 2021-01-16 10:53

    Try adding

    DEFINES += _WIN32
    

    to your project file.

    0 讨论(0)
  • 2021-01-16 10:54

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

    0 讨论(0)
  • 2021-01-16 10:55

    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.

    0 讨论(0)
提交回复
热议问题