Skip to content Skip to sidebar Skip to footer

Cannot Build Local Shared Library In Android Ndk

I want to build library .so for version 4.0.3 but I am unable to do so. What I feel is that these problems are caused because my .mk file is not linking with the libraries. Android

Solution 1:

Android NDK supports pthreads, but does not provide libpthread as usual in Linux toolchains. Your first error message will be gone if you use

LOCAL_CFLAGS += -DHAVE_PTHREADS

and not add LOCAL_LDLIBS += -lpthread

Regarding the undefined reference to do_copy(), it comes from system library libutils.so. It is not safe to use libraries that are not officially published with NDK (see more here), so you better rewrite this piece of code.

Probably you received your Android.mk file from the google source or one of its forks. I doubt that the resulting library will be useable, because the original libbinder.sorequires system app with elevated permissions will be loaded when your app starts.

Anyways, referring to system libraries as LOCAL_SHARED_LIBRARIES does not work with ndk-build. Instead of LOCAL_SHARED_LIBRARIES := liblog libcutils libutils you are expected to write

LOCAL_LDLIBS += -llog -lcutils -lutils

Post a Comment for "Cannot Build Local Shared Library In Android Ndk"