2

I want my executable to be able to call functions supported by libcuils - like property_get(...).

In the Android.mk I have: LOCAL_LDLIBS:=-lcutils

ndk-build returns: undefined reference to property_get

Adding 'default.properties' with target=android-9 didn't help.

I'm using android-ndk-r8e on ubuntu.

Bush
  • 2,433
  • 5
  • 34
  • 57

1 Answers1

3

libcutils.so is not part of official native API, it is not distributed with NDK. You can pull it from any device or even from emulator, and it is reasonable stable across the versions and mods, so I will not discourage you from using it.

On the other hand, the linker would normally say

ld: error: cannot find -lcutils
collect2: ld returned 1 exit status

If it said undefined reference, it probably found libcutils.so somewhere on its search path. Maybe, it was a wrong library. Maybe, you set LOCAL_LDLIBS for a static library in your Android.mk, and therefore it is ignored.

LOCAL_LDLIBS is only relevant for

include $(BUILD_SHARED_LIBRARY)

or

include $(BUILD_EXECUTABLE)
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307