BroadbandForum / obuspa

OB-USP-AGENT is a system daemon providing a User Services Platform (USP) Agent. https://github.com/BroadbandForum/obuspa/wiki
BSD 3-Clause "New" or "Revised" License
88 stars 61 forks source link

Error building on macOS #22

Closed RamonRomeroQro closed 3 years ago

RamonRomeroQro commented 3 years ago

Hello!

Nice work on this project.

I am having this error building on macOS 11.5.1, any idea on how to solve it or which may be my mistake?

ramonromeroqro@Ramons-MacBook-Air ~/D/obuspa (master)> make
gcc -DPACKAGE_NAME=\"ob-uspagent\" -DPACKAGE_TARNAME=\"ob-uspagent\" -DPACKAGE_VERSION=\"1.0.0\" -DPACKAGE_STRING=\"ob-uspagent\ 1.0.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"ob-uspagent\" -DVERSION=\"1.0.0\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_WCHAR_H=1 -DSTDC_HEADERS=1 -D_ALL_SOURCE=1 -D_DARWIN_C_SOURCE=1 -D_GNU_SOURCE=1 -D_HPUX_ALT_XOPEN_SOCKET_API=1 -D_NETBSD_SOURCE=1 -D_OPENBSD_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D__STDC_WANT_IEC_60559_ATTRIBS_EXT__=1 -D__STDC_WANT_IEC_60559_BFP_EXT__=1 -D__STDC_WANT_IEC_60559_DFP_EXT__=1 -D__STDC_WANT_IEC_60559_FUNCS_EXT__=1 -D__STDC_WANT_IEC_60559_TYPES_EXT__=1 -D__STDC_WANT_LIB_EXT2__=1 -D__STDC_WANT_MATH_SPEC_FUNCS__=1 -D_TANDEM_SOURCE=1 -D__EXTENSIONS__=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DENABLE_COAP=1 -DENABLE_MQTT=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_EXECINFO_H=1 -I.  -I/opt/homebrew/Cellar/openssl@1.1/1.1.1k/include    -I/opt/homebrew/Cellar/mosquitto/2.0.10_1/include -DOBUSPA_LOCAL_STATE_DIR=\""/usr/local/var/obuspa"\" -I./src -I./src/core -I./src/protobuf-c -I./src/vendor -I./src/libjson/ccan/json -I./src/include -Werror -Werror=unused-value -Werror=format -Winit-self -Wparentheses -Werror=parentheses -Wuninitialized -Werror=uninitialized -Wpointer-arith -I/opt/homebrew/opt/openssl@1.1/include -Wall -Wfatal-errors -g -O2 -MT src/core/obuspa-nu_ipaddr.o -MD -MP -MF src/core/.deps/obuspa-nu_ipaddr.Tpo -c -o src/core/obuspa-nu_ipaddr.o `test -f 'src/core/nu_ipaddr.c' || echo './'`src/core/nu_ipaddr.c
src/core/nu_ipaddr.c:127:21: fatal error: no member named 's6_addr32' in 'struct in6_addr'
                p->s_addr = addr->s6_addr32[3];
                            ~~~~  ^
1 error generated.
make: *** [src/core/obuspa-nu_ipaddr.o] Error 1
holme-r commented 3 years ago

To get it to build, you could try disabling the IPv6 aspects of nu_ipaddr.c (#define IPV6_NUIPADDR 0 in nu_ipaddr.h). Fixing the code properly to work for IPv6 on MacOS would need more changes. OBUSPA was originally designed to compile with glibc. But Bionic and MUSL are happy with the code too. I guess some of the IPv6 fields in the structure are named differently on the MAC.

RamonRomeroQro commented 3 years ago

Yep, getting rid of those dependant lines seems to work ( changing the flag on nu_ipaddr.c did not work, had to do it manually. Maybe related to Clang ? 🤔 )

After that, this error pops:

src/core/nu_macaddr.c:128:23: fatal error: use of undeclared identifier 'SIOCGIFHWADDR'
    err = ioctl(sock, SIOCGIFHWADDR, &ifr);
                      ^
1 error generated.

Which seem to be a direct dependency with Linux systems (SO post related)

So, I will follow with the Docker approach.

Thanks!