Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile errors in qtzeroconf on Windows with MinGW #326

Closed
zehnm opened this issue Nov 3, 2019 · 7 comments
Assignees
Labels
bug

Comments

@zehnm
Copy link
Member

@zehnm zehnm commented Nov 3, 2019

The Windows 10 development environment has been setup according to:
https://github.com/YIO-Remote/remote-software/blob/master/DEV%20ENVIRONMENT.md#windows

However there are multiple errors in the qtzeroconf / bonjour-sdk module.

  • unknown type name int64_t
D:/projects/yio/remote-software/qtzeroconf/bonjour-sdk/CommonServices.h:771:9: error: unknown type name 'int64_t'
 typedef int64_t int_least64_t;
         ^~~~~~~

This could be fixed with #include <stdint.h>in CommonServices.h in the #elif ( TARGET_OS_WIN32 ) block starting at line 234:

    #if ( defined( __MINGW32__ ) )
        #include <stdint.h>
    #endif

Looks like MinGW behaves differently than other compilers.

  • struct sockaddr_un not defined and others:
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c: In function 'SetUDSPath':
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:181:31: error: dereferencing pointer to incomplete type 'struct sockaddr_un'
     if (pathLen < sizeof(saddr->sun_path))
                               ^~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c: In function 'FreeDNSServiceOp':
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:433:30: warning: variable 'op_were_not_going_to_free_but_we_need_to_fool_the_analyzer' set but not used [-Wunused-but-set-variable]
         static DNSServiceOp *op_were_not_going_to_free_but_we_need_to_fool_the_analyzer;
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c: In function 'ConnectToServer':
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:473:22: error: storage size of 'saddr' isn't known
     dnssd_sockaddr_t saddr;
                      ^~~~~
In file included from ..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:32:0:
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_ipc.h:89:65: error: dereferencing pointer to incomplete type 'struct sockaddr_un'
 #   define MAX_CTLPATH          (sizeof(((struct sockaddr_un*)0)->sun_path))
                                                                 ^
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_ipc.h:89:65: note: in definition of macro 'MAX_CTLPATH'
 #   define MAX_CTLPATH          (sizeof(((struct sockaddr_un*)0)->sun_path))
                                                                 ^~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:473:22: warning: unused variable 'saddr' [-Wunused-variable]
     dnssd_sockaddr_t saddr;
                      ^~~~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c: In function 'deliver_request':
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:713:17: warning: implicit declaration of function 'socketpair'; did you mean 'socket'? [-Wimplicit-function-declaration]
             if (socketpair(AF_DNSSD, SOCK_STREAM, 0, sp) < 0) deliver_request_bailout("socketpair");
                 ^~~~~~~~~~
                 socket
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:16: error: variable 'vec' has initializer but incomplete type
         struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
                ^~~~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:30: warning: excess elements in struct initializer
         struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
                              ^
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:30: note: (near initialization for 'vec')
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:77: warning: excess elements in struct initializer
         struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
                                                                             ^
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:77: note: (near initialization for 'vec')
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:22: error: storage size of 'vec' isn't known
         struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
                      ^~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:784:23: error: storage size of 'msg' isn't known
         struct msghdr msg;
                       ^~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:786:19: warning: implicit declaration of function 'CMSG_SPACE'; did you mean 'C1_SPACE'? [-Wimplicit-function-declaration]
         char cbuf[CMSG_SPACE(4 * sizeof(dnssd_sock_t))];
                   ^~~~~~~~~~
                   C1_SPACE
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:802:32: warning: implicit declaration of function 'open'; did you mean 'fopen'? [-Wimplicit-function-declaration]
                     listenfd = open(p, O_RDWR, 0);
                                ^~~~
                                fopen
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:802:40: error: 'O_RDWR' undeclared (first use in this function); did you mean 'CLRDTR'?
                     listenfd = open(p, O_RDWR, 0);
                                        ^~~~~~
                                        CLRDTR
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:802:40: note: each undeclared identifier is reported only once for each function it appears in
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:810:34: warning: implicit declaration of function 'CMSG_LEN'; did you mean 'CALG_TEK'? [-Wimplicit-function-declaration]
             msg.msg_controllen = CMSG_LEN(sizeof(dnssd_sock_t));
                                  ^~~~~~~~
                                  CALG_TEK
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:812:20: warning: implicit declaration of function 'CMSG_FIRSTHDR'; did you mean 'PSN_FIRST'? [-Wimplicit-function-declaration]
             cmsg = CMSG_FIRSTHDR(&msg);
                    ^~~~~~~~~~~~~
                    PSN_FIRST
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:813:17: error: dereferencing pointer to incomplete type 'struct cmsghdr'
             cmsg->cmsg_len     = CMSG_LEN(sizeof(dnssd_sock_t));
                 ^~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:815:34: error: 'SCM_RIGHTS' undeclared (first use in this function); did you mean 'SS_RIGHT'?
             cmsg->cmsg_type    = SCM_RIGHTS;
                                  ^~~~~~~~~~
                                  SS_RIGHT
In file included from d:/development/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/windows.h:95:0,
                 from d:/development/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/winsock2.h:23,
                 from ..\remote-software\qtzeroconf\bonjour-sdk\dns_sd.h:100,
                 from ..\remote-software\qtzeroconf\bonjour-sdk\dnssd_ipc.h:32,
                 from ..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:32:
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:816:31: error: called object is not a function or function pointer
             *((dnssd_sock_t *)CMSG_DATA(cmsg)) = listenfd;
                               ^
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:831:13: warning: implicit declaration of function 'sendmsg'; did you mean 'sendto'? [-Wimplicit-function-declaration]
         if (sendmsg(sdr->sockfd, &msg, 0) < 0)
             ^~~~~~~
             sendto
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:784:23: warning: unused variable 'msg' [-Wunused-variable]
         struct msghdr msg;
                       ^~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:783:22: warning: unused variable 'vec' [-Wunused-variable]
         struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
                      ^~~
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c: In function 'handle_addrinfo_response':
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:1453:17: error: 'struct sockaddr_in' has no member named 'sin_len'; did you mean 'sin_zero'?
             sa4.sin_len = sizeof(struct sockaddr_in);
                 ^~~~~~~
                 sin_zero
..\remote-software\qtzeroconf\bonjour-sdk\dnssd_clientstub.c:1463:17: error: 'struct sockaddr_in6' has no member named 'sin6_len'; did you mean 'sin6_port'?
             sa6.sin6_len = sizeof(struct sockaddr_in6);
                 ^~~~~~~~
                 sin6_port

My assumption is that MinGW is not suited for this project on Windows.
Has anyone got this running on Windows? E.g. with the Visual Studio compiler?

@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 3, 2019

Further analysis:

  • Installed VS 2019: no support in Qt Creator :-(
  • Installed VS 2017
    • Qt Creator didn't fully detect VS kits (different compiler paths for C / C++).
    • VS Compiler is way more restrictive (which is a good thing) and flagged all methods without a return value . --> easy fix
  • struct sockaddr_un is a Unix only structure!
    • For Windows there's another configuration defined in qtzeroconf.pri:
win32 {
	DEFINES+= WIN32
	DEFINES+= NDEBUG
	DEFINES+= _WINDOWS
	DEFINES+= _USRDLL
	DEFINES+= MDNS_DEBUGMSGS=0
	DEFINES+= WIN32_LEAN_AND_MEAN
	DEFINES+= USE_TCP_LOOPBACK
	DEFINES+= _CRT_SECURE_NO_DEPRECATE
	DEFINES+= _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1
	DEFINES+= NOT_HAVE_SA_LEN
	QMAKE_CFLAGS+= -I$$PWD/bonjour-sdk
	QMAKE_CXXFLAGS+= -I$$PWD/bonjour-sdk -I$$PWD
	HEADERS+= $$PWD/qzeroconf.h $$PWD/bonjour_p.h
	SOURCES+= $$PWD/bonjour.cpp
	SOURCES+= $$PWD/bonjour-sdk/dnssd_clientlib.c
	SOURCES+= $$PWD/bonjour-sdk/dnssd_clientstub.c
	SOURCES+= $$PWD/bonjour-sdk/dnssd_ipc.c
	LIBS+= -lws2_32 -lwsock32
}
  • Important are USE_TCP_LOOPBACK & NOT_HAVE_SA_LEN

However they are NOT considered during a build!?
Manually defining them in dnssd_clientstub.c & .h makes it work. So there's something wrong with the Qt project setup!

@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 3, 2019

Got that little bugger! The problem was in remote.pro overriding all DEFINES:

include(qtzeroconf/qtzeroconf.pri)
DEFINES = QZEROCONF_STATIC

This is wrong and overrides all previous DEFINES in qtzeroconf.pri! Correct:

include(qtzeroconf/qtzeroconf.pri)
DEFINES += QZEROCONF_STATIC
@zehnm zehnm self-assigned this Nov 3, 2019
@martonborzak

This comment has been minimized.

Copy link
Member

@martonborzak martonborzak commented Nov 3, 2019

Good catch @zehnm ! :)

zehnm added a commit that referenced this issue Nov 3, 2019
- Fixed DEFINES in remote.pro to not override defines of qtzeroconf
- Additional include for MinGW in CommonServices.h
- Fixed missing returns for MSVC compiler

This fixes #326
@zehnm zehnm removed the help wanted label Nov 3, 2019
@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 3, 2019

Fixed in feature/project-setup branch. This issue will be resolved once #324 is merged to dev

@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 3, 2019

One step closer to a working Windows app! All resources should be copied now at the right place. Unfortunately the plugin loading is still broken.
YIO-remote-Win10

zehnm added a commit that referenced this issue Nov 3, 2019
- Added missing resources in destination copy
- Fixed plugin loading on Windows
- Simplified plugin loading code

Also part of #324
@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 3, 2019

Plugin loading fixed :-) Test case with only ir plugin inside plugins folder:

LOADING PLUGIN: "D:/projects/yio/binaries/windows/gcc/x86/debug/plugins/appletv.dll"
FAILED TO LOAD PLUGIN:  "The shared library was not found."
LOADING PLUGIN: "D:/projects/yio/binaries/windows/gcc/x86/debug/plugins/homeassistant.dll"
FAILED TO LOAD PLUGIN:  "The shared library was not found."
LOADING PLUGIN: "D:/projects/yio/binaries/windows/gcc/x86/debug/plugins/ir.dll"
qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional.

Non available plugins fail, IR plugin succeeds.

@zehnm

This comment has been minimized.

Copy link
Member Author

@zehnm zehnm commented Nov 5, 2019

Fixed in dev branch

@zehnm zehnm closed this Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.