0

I'm trying to figure out why I keep getting undefined references to functions that are declared in shared libraries that come with android.

My application.mk and root android.mk

APP_MODULES := adhoc APP_STL := gnustl_shared NDK_TOOLCHAIN_VERSION=clang3.1 APP_OPTIM := debug CUR_PATH := $(call my-dir) LOCAL_CPPFLAGS += -std-c++11 -Wwrite-strings include $(CUR_PATH)/native/adhoc/Android.mk 

adhoc Android.mk

LOCAL_PATH := $(call my-dir) updater_src_files := \ install.cpp\ sha1.cpp\ addhoc_lib.cpp include $(CLEAR_VARS) LOCAL_SRC_FILES := $(updater_src_files) inc_path = $(NDK_ROOT)/../AndroidSource/system/core/include \ $(NDK_ROOT)/../AndroidSource/hardware/libhardware_legacy/include LOCAL_C_INCLUDES += $(inc_path) LOCAL_CFLAGS := -DINTERNAL_SHA1 -DCONFIG_CRYPTO_INTERNAL -DCONFIG_NO_T_PRF -DCONFIG_NO_TLS_PRF -std=c++11 -Wc++11-extensions -Wno-deprecated-writable-strings LOCAL_STATIC_LIBRARIES := libedify LOCAL_SHARED_LIBRARIES := libcutils\ libhardware_legacy\ libc\ libnetutils\ libsysutils LOCAL_MODULE := adhoc include $(BUILD_SHARED_LIBRARY) $(call import-add-path, $(LOCAL_PATH)) $(call import-module, edify) 

and adhoc/edify/android.mk

LOCAL_PATH := $(call my-dir) edify_src_files := \ lexer.l \ parser.y \ expr.c include $(CLEAR_VARS) LOCAL_SRC_FILES := $(edify_src_files) LOCAL_CFLAGS := $(edify_cflags) LOCAL_MODULE := edify include $(BUILD_STATIC_LIBRARY) 

I get output from ndk-build -B V=1 like:

SharedLibrary : libadhoc.so /home/corey/Android_Dev/android-ndk-r8d/toolchains/llvm-3.1/prebuilt/linux-x86/bin/clang++ -Wl,-soname,libadhoc.so -shared --sysroot=/home/corey/Android_Dev/android-ndk-r8d/platforms/android-14/arch-arm ./obj/local/armeabi/objs-debug/adhoc/install.o ./obj/local/armeabi/objs-debug/adhoc/sha1.o ./obj/local/armeabi/objs-debug/adhoc/addhoc_lib.o ./obj/local/armeabi/libedify.a ./obj/local/armeabi/libgnustl_shared.so -gcc-toolchain /home/corey/Android_Dev/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86 -no-canonical-prefixes -target armv5te-none-linux-androideabi -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now /home/corey/Android_Dev/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libsupc++.a -lc -lm -o ./obj/local/armeabi/libadhoc.so /home/corey/Android_Dev/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs-debug/adhoc/install.o: in function GetPropFn(char const*, State*, int, Expr**):jni/native/adhoc/install.cpp:463: error: undefined reference to 'property_get' 

1 Answer 1

1

If you are using C++ code, then add C PLUS PLUS flag.

#ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif 

Also take a look at the following post. android ndk undefined reference to a method

Sign up to request clarification or add additional context in comments.

1 Comment

Well I got it to work by copying the libraries off my phone and giving the build system a path to them. I already had the header files wrapped with extern "C".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.