obgm / libcoap

A CoAP (RFC 7252) implementation in C
Other
793 stars 423 forks source link

Libcoap cannot be compiled using the minGW compiler on Windows 10 #1061

Closed MrHulu closed 1 year ago

MrHulu commented 1 year ago

Hello, I have encountered an issue where libcoap cannot be compiled using the minGW compiler on Windows 10 system! My minGW compiler was downloaded and installed through MSYS. Does libcoap not support compilation with minGW on Windows? I used the mvsc compiler and it worked, it passed. I need help, I need help, thanks a lot!

Environment

Problem Description

libcoap cannot be compiled using the minGW compiler on Windows 10 system!

Debug Logs

config Release --target install --
[build] [6/38   2% :: 4.660] Building C object CMakeFiles/coap-3.dir/src/coap_address.c.obj
[build] [7/38   5% :: 4.699] Building C object CMakeFiles/coap-3.dir/src/coap_cache.c.obj
[build] [8/38   7% :: 4.703] Building C object CMakeFiles/coap-3.dir/src/coap_asn1.c.obj
[build] [9/38  10% :: 4.718] Building C object CMakeFiles/coap-3.dir/src/coap_async.c.obj
[build] [10/38  13% :: 4.990] Building C object CMakeFiles/coap-3.dir/src/coap_debug.c.obj
[build] [11/38  15% :: 5.742] Building C object CMakeFiles/coap-server.dir/examples/coap-server.c.obj
[build] ../examples/coap-server.c:33:1: warning: declaration of 'strndup' shadows a built-in function [-Wshadow]
[build]    33 | strndup(const char* s1, size_t n) {
[build]       | ^~~~~~~
[build] ../examples/coap-server.c:40:2: warning: ISO C does not allow extra ';' outside of a function [-Wpedantic]
[build]    40 | };
[build]       |  ^
[build] In file included from include/coap3/coap.h:43,
[build]                  from ../examples/coap-server.c:65:
[build] ../include/coap3/libcoap.h:29: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
[build]    29 | #pragma comment(lib,"Ws2_32.lib")
[build]       | 
[build] ../examples/coap-server.c: In function 'main':
[build] ../examples/coap-server.c:2718:36: warning: passing argument 3 of 'getopt' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
[build]  2718 |   while ((opt = getopt(argc, argv, "c:d:eg:G:h:i:j:J:k:l:mnp:rs:u:v:A:C:E:L:M:NP:R:S:T:U:V:X:")) != -1) {
[build]       |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from ../examples/coap-server.c:25:
[build] ../examples/getopt.c:24:38: note: expected 'char *' but argument is of type 'const char *'
[build]    24 | getopt(int argc, char *argv[], char *opts)
[build]       |                                ~~~~~~^~~~
[build] ../examples/coap-server.c:3042: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
[build]  3042 | #pragma warning( disable : 4090 )
[build]       | 
[build] ../examples/getopt.c: At top level:
[build] ../examples/getopt.c:18:12: warning: 'opterr' defined but not used [-Wunused-variable]
[build]    18 | static int opterr = 1;
[build]       |            ^~~~~~
[build] [12/38  18% :: 9.134] Building C object CMakeFiles/coap-3.dir/src/coap_encode.c.obj
[build] [13/38  21% :: 9.434] Building C object CMakeFiles/coap-3.dir/src/coap_event.c.obj
[build] [14/38  23% :: 9.453] Building C object CMakeFiles/coap-3.dir/src/coap_mem.c.obj
[build] [15/38  26% :: 9.491] Building C object CMakeFiles/coap-3.dir/src/coap_notls.c.obj
[build] [16/38  28% :: 9.532] Building C object CMakeFiles/coap-3.dir/src/coap_hashkey.c.obj
[build] [17/38  31% :: 10.022] Building C object CMakeFiles/coap-3.dir/src/coap_io.c.obj
[build] FAILED: CMakeFiles/coap-3.dir/src/coap_io.c.obj 
[build] D:\msys\mingw64\bin\gcc.exe  -I. -Iinclude -I../include -isystem D:/Qt/Tools/OpenSSL/Win_x64/include -O3 -DNDEBUG -DLIBCOAP_PACKAGE_BUILD=\"v4.3.1-91-g78304f4-dirty\" -std=gnu99 -MD -MT CMakeFiles/coap-3.dir/src/coap_io.c.obj -MF CMakeFiles\coap-3.dir\src\coap_io.c.obj.d -o CMakeFiles/coap-3.dir/src/coap_io.c.obj -c ../src/coap_io.c
[build] ../src/coap_io.c:569:1: warning: 'thread' attribute directive ignored [-Wattributes]
[build]   569 | static __declspec(thread) LPFN_WSARECVMSG lpWSARecvMsg = NULL;
[build]       | ^~~~~~
[build] ../src/coap_io.c: In function 'coap_network_send':
[build] ../src/coap_io.c:614:14: warning: implicit declaration of function 'CMSG_SPACE'; did you mean 'C1_SPACE'? [-Wimplicit-function-declaration]
[build]   614 |     char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
[build]       |              ^~~~~~~~~~
[build]       |              C1_SPACE
[build] ../src/coap_io.c:646:16: warning: implicit declaration of function 'CMSG_FIRSTHDR'; did you mean 'WSA_CMSG_FIRSTHDR'? [-Wimplicit-function-declaration]
[build]   646 |         cmsg = CMSG_FIRSTHDR(&mhdr);
[build]       |                ^~~~~~~~~~~~~
[build]       |                WSA_CMSG_FIRSTHDR
[build] ../src/coap_io.c:646:14: warning: assignment to 'struct cmsghdr *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[build]   646 |         cmsg = CMSG_FIRSTHDR(&mhdr);
[build]       |              ^
[build] ../src/coap_io.c:647:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   647 |         cmsg->cmsg_level = SOL_IP;
[build]       |             ^~
[build] ../src/coap_io.c:648:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   648 |         cmsg->cmsg_type = IP_PKTINFO;
[build]       |             ^~
[build] ../src/coap_io.c:649:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   649 |         cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
[build]       |             ^~
[build] ../src/coap_io.c:649:26: warning: implicit declaration of function 'CMSG_LEN' [-Wimplicit-function-declaration]
[build]   649 |         cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
[build]       |                          ^~~~~~~~
[build] ../src/coap_io.c:675:14: warning: assignment to 'struct cmsghdr *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[build]   675 |         cmsg = CMSG_FIRSTHDR(&mhdr);
[build]       |              ^
[build] ../src/coap_io.c:676:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   676 |         cmsg->cmsg_level = IPPROTO_IPV6;
[build]       |             ^~
[build] ../src/coap_io.c:677:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   677 |         cmsg->cmsg_type = IPV6_PKTINFO;
[build]       |             ^~
[build] ../src/coap_io.c:678:13: error: invalid use of undefined type 'struct cmsghdr'
[build]   678 |         cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
[build]       |             ^~
[build] ../src/coap_io.c:698:12: warning: assignment to 'struct cmsghdr *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[build]   698 |       cmsg = CMSG_FIRSTHDR(&mhdr);
[build]       |            ^
[build] ../src/coap_io.c:699:11: error: invalid use of undefined type 'struct cmsghdr'
[build]   699 |       cmsg->cmsg_level = SOL_IP;
[build]       |           ^~
[build] ../src/coap_io.c:700:11: error: invalid use of undefined type 'struct cmsghdr'
[build]   700 |       cmsg->cmsg_type = IP_PKTINFO;
[build]       |           ^~
[build] ../src/coap_io.c:701:11: error: invalid use of undefined type 'struct cmsghdr'
[build]   701 |       cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
[build]       |           ^~
[build] ../src/coap_io.c: In function 'coap_network_read':
[build] ../src/coap_io.c:839:9: error: invalid use of undefined type 'struct cmsghdr'
[build]   839 |     cmsg->cmsg_len = CMSG_LEN(sizeof(buf));
[build]       |         ^~
[build] ../src/coap_io.c:840:9: error: invalid use of undefined type 'struct cmsghdr'
[build]   840 |     cmsg->cmsg_level = -1;
[build]       |         ^~
[build] ../src/coap_io.c:841:9: error: invalid use of undefined type 'struct cmsghdr'
[build]   841 |     cmsg->cmsg_type = -1;
[build]       |         ^~
[build] ../src/coap_io.c:885:17: warning: assignment to 'struct cmsghdr *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[build]   885 |       for (cmsg = CMSG_FIRSTHDR(&mhdr); cmsg; cmsg = CMSG_NXTHDR(&mhdr, cmsg)) {
[build]       |                 ^
[build] ../src/coap_io.c:885:54: warning: implicit declaration of function 'CMSG_NXTHDR'; did you mean 'WSA_CMSG_NXTHDR'? [-Wimplicit-function-declaration]
[build]   885 |       for (cmsg = CMSG_FIRSTHDR(&mhdr); cmsg; cmsg = CMSG_NXTHDR(&mhdr, cmsg)) {
[build]       |                                                      ^~~~~~~~~~~
[build]       |                                                      WSA_CMSG_NXTHDR
[build] ../src/coap_io.c:885:52: warning: assignment to 'struct cmsghdr *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[build]   885 |       for (cmsg = CMSG_FIRSTHDR(&mhdr); cmsg; cmsg = CMSG_NXTHDR(&mhdr, cmsg)) {
[build]       |                                                    ^
[build] ../src/coap_io.c:888:17: error: invalid use of undefined type 'struct cmsghdr'
[build]   888 |         if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) {
[build]       |                 ^~
[build] ../src/coap_io.c:888:53: error: invalid use of undefined type 'struct cmsghdr'
[build]   888 |         if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) {
[build]       |                                                     ^~
[build] ../src/coap_io.c:903:17: error: invalid use of undefined type 'struct cmsghdr'
[build]   903 |         if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO) {
[build]       |                 ^~
[build] ../src/coap_io.c:903:47: error: invalid use of undefined type 'struct cmsghdr'
[build]   903 |         if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO) {
[build]       |                                               ^~
[build] ../src/coap_io.c:935:19: error: invalid use of undefined type 'struct cmsghdr'
[build]   935 |           if (cmsg->cmsg_level != -1 && cmsg->cmsg_type != -1) {
[build]       |                   ^~
[build] ../src/coap_io.c:935:45: error: invalid use of undefined type 'struct cmsghdr'
[build]   935 |           if (cmsg->cmsg_level != -1 && cmsg->cmsg_type != -1) {
[build]       |                                             ^~
[build] In file included from ../include/coap3/coap_net.h:37,
[build]                  from ../include/coap3/coap_async.h:20,
[build]                  from include/coap3/coap.h:47,
[build]                  from ../include/coap3/coap_internal.h:53,
[build]                  from ../src/coap_io.c:16:
[build] ../src/coap_io.c:938:26: error: invalid use of undefined type 'struct cmsghdr'
[build]   938 |                      cmsg->cmsg_level, cmsg->cmsg_type);
[build]       |                          ^~
[build] ../include/coap3/coap_debug.h:220:29: note: in definition of macro 'coap_log'
[build]   220 |      coap_log_impl((level), __VA_ARGS__); \
[build]       |                             ^~~~~~~~~~~
[build] ../src/coap_io.c:936:13: note: in expansion of macro 'coap_log_debug'
[build]   936 |             coap_log_debug(
[build]       |             ^~~~~~~~~~~~~~
[build] ../src/coap_io.c:938:44: error: invalid use of undefined type 'struct cmsghdr'
[build]   938 |                      cmsg->cmsg_level, cmsg->cmsg_type);
[build]       |                                            ^~
[build] ../include/coap3/coap_debug.h:220:29: note: in definition of macro 'coap_log'
[build]   220 |      coap_log_impl((level), __VA_ARGS__); \
[build]       |                             ^~~~~~~~~~~
[build] ../src/coap_io.c:936:13: note: in expansion of macro 'coap_log_debug'
[build]   936 |             coap_log_debug(
[build]       |             ^~~~~~~~~~~~~~