Cannot build local shared library in Android Ndk

旧街凉风 提交于 2019-12-01 12:35:39
Alex Cohn

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.so requires 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!