Skip to content

Cannot build liblsl due to missing getifaddrs and freeifaddrs in liblsl >= 1.14 #4

@cboulay

Description

@cboulay

The relatively recent addition of netinterfaces.cpp to liblsl uses unix functions that are creating some trouble for me when trying to compile in Android Studio. Specifically, it is complaining error: use of undeclared identifier 'getifaddrs' (and similarly for freeifaddrs).

It's strange that it doesn't complain about lack of ifaddrs generally, meaning it must find that include in the Android NDK.
Within the Android NDK ifaddrs.h, both getifaddrs and freeifaddrs are behind the #if __ANDROID_API__ >= 24 guard. I'm currently targeting API 30 so I'm pretty sure I meet these criteria, but I can't be sure this preprocessor definition exists.

If I run ninja -v from within the intermediate build directory, I get the following:

[4/12] D:\Tools\Misc\AndroidSDK\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi16 --gcc-toolchain=D:/Tools/Misc/AndroidSDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/Tools/Misc/AndroidSDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot -DBOOST_ALL_NO_LIB -DBOOST_ASIO_SEPARATE_COMPILATION -DBOOST_ASIO_STANDALONE -DBOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -DLIBLSL_EXPORTS -DLOGURU_DEBUG_LOGGING=0 -I. -ID:/Tools/Neurophys/labstreaminglayer/LSL/liblsl -ID:/Tools/Neurophys/labstreaminglayer/LSL/liblsl/include -ID:/Tools/Neurophys/labstreaminglayer/LSL/liblsl/lslboost -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -frtti -fexceptions -O0 -fno-limit-debug-info -fPIC -fvisibility=hidden -MD -MT CMakeFiles/lslobj.dir/src/netinterfaces.cpp.o -MF CMakeFiles\lslobj.dir\src\netinterfaces.cpp.o.d -o CMakeFiles/lslobj.dir/src/netinterfaces.cpp.o -c D:/Tools/Neurophys/labstreaminglayer/LSL/liblsl/src/netinterfaces.cpp

I don't see __ANDROID_API__ there but I don't know if that list is exhaustive. My understanding is that --target={} implies some __ANDROID_API__ value but I don't know.

I tried adding a -D__ANDROID_API__=30 to the liblsl-Java build.gradle, and I tried commenting out the #ifdef guard in the NDK, but neither of those worked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions