Bug 349303 - Compilation errors with MinGW
Summary: Compilation errors with MinGW
Status: REPORTED
Alias: None
Product: frameworks-kdnssd
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Matthew Dawson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-17 18:24 UTC by Calle Laakkonen
Modified: 2019-01-20 15:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Fix to dnssd callback related mingw compiler errors (1.81 KB, patch)
2015-06-17 18:24 UTC, Calle Laakkonen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Calle Laakkonen 2015-06-17 18:24:56 UTC
Created attachment 93217 [details]
Fix to dnssd callback related mingw compiler errors

When compiling KDNSSD with mingw (installed with the Qt installer), I got the following error:

C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp: In member function 'void KDNSSD::DomainBrowser::startBrowse()':
C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp:52:83: error: invalid conversion from 'void (*)(DNSServiceRef, DNSServiceFlags, uint32_t, DNSServiceErrorType, const char*, void*) {aka void (*)(_DNSServiceRef_t*, unsigned int, unsigned int, int, const char*, void*)}' to 'DNSServiceDomainEnumReply {aka void (__attribute__((__stdcall__)) *)(_DNSServiceRef_t*, unsigned int, unsigned int, int, const char*, void*)}' [-fpermissive]
                                    0, domain_callback, reinterpret_cast<void *>(d)) == kDNSServiceErr_NoError) {
                                                                                   ^
In file included from C:\dev\kdnssd\src\mdnsd-responder.h:26:0,
                 from C:\dev\kdnssd\src\mdnsd-domainbrowser_p.h:24,
                 from C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp:21:
C:/PROGRA~1/BONJOU~1/Include/dns_sd.h:859:31: note: initializing argument 4 of 'DNSServiceErrorType DNSServiceEnumerateDomains(_DNSServiceRef_t**, DNSServiceFlags, uint32_t, DNSServiceDomainEnumReply, void*)'
 DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains
                               ^
mingw32-make[2]: *** [src/CMakeFiles/KF5DNSSD.dir/mdnsd-domainbrowser.cpp.obj] Error 1
mingw32-make[1]: *** [src/CMakeFiles/KF5DNSSD.dir/all] Error 2
mingw32-make: *** [all] Error 2


I managed to fix this error by adding DNSSD_API to the callback function declarations. (Patch attached.)

I also got another error about the "netinet/in.h" include in mdnsd-publicservice.cpp.
I got it working by replacing it with "Winsock2.h" and adding ws2_32 to target_link_libraries.
Another way would be to use the functions from QtEndian instead of ntohs/htons to avoid platform specific includes.

After these changes I managed to successfully compile KDNSSD with Bonjour.
Comment 1 Matthew Dawson 2015-06-18 03:01:47 UTC
Hi Calle,

Thanks for looking into this and submitting a patch!  I unfortunately won't have time to review this patch until the weekend.

In the future, I recommend putting patches on reviewboard ( https://git.reviewboard.kde.org/ ) as they get more visibility there (bug reports are always fine here!).  If you don't mind, it would be good to put that patch there, but we can merge it in its current form just fine as well :)

Thanks again!
Comment 2 Christoph Feck 2018-12-21 01:54:57 UTC
According to our CI, kdnssd builds fine with MSVC, see https://build.kde.org/job/Frameworks/job/kdnssd/

Is this still an issue with MinGW?
Comment 3 Christoph Feck 2019-01-17 03:39:13 UTC
If you can provide the information requested in comment #2, please add it.
Comment 4 Calle Laakkonen 2019-01-20 15:31:33 UTC
I'm now using GCC 5.5.0 in MXE to build my application and am no longer encountering the first error. I do however get an error about missing "netinet/in.h".
Currently, I'm working around this by replacing "netinet/in.h" with <QtEndian> and ntohs and htons calls with qFromBigEndian and qToBigEndian calls.