Search code examples
windowsqtbonjourzeroconf

QT dns_sd.h UINT8 does not name a type


This is a zeroconf example I'm trying to compile on Windows. I also downloaded bonjour sdk for Windows from Apple.

I'm using Qt Version (4.6.2) and Qt Creator 1.3.1, not sure if it is relevant.

When I compile, it complains about 'UINT8' does not name a type in dns_sd.h. I tried to include stdint.h before dns_sd.h, shown as below:

#include <stdint.h>
#include <dns_sd.h>

But QT still complains about the same errors. Even though I go into stdint.h and there is a declaration for uint8_t.

This post suggests to convert .lib to .a, since we can't link a gcc program to a MSVC lib. I tried but it did not solve the problem. Here is the .pro file

HEADERS       = client.h \
            bonjourservicebrowser.h \
            bonjourserviceresolver.h
SOURCES       = client.cpp \
            main.cpp \
            bonjourservicebrowser.cpp \
            bonjourserviceresolver.cpp
QT           += network

!mac:x11:LIBS+=-ldns_sd
win32:LIBS+=-ldnssd
LIBPATH += "C:/Tools/reimp_new/bin"
INCLUDEPATH += "C:/Program Files/Bonjour SDK/Include"

I put the libdnssd.a in the path of C:\Tools\reimp_new\bin.

Error is still happening :(


Solution

  • Added this before including dns_sd.h fixes it.

    #define _MSL_STDINT_H
    #include <stdint.h>
    #include <dns_sd.h>
    

    I also tried to use the original lib file, it still work. So probably there is no need to convert the .lib to .a