3

Recently upgraded to NDK r5b, and the build fails with "undefined reference" to functions located in a static library.

Here is the error

/home/brian/workspace/VoiceEngineDemo/obj/local/armeabi-v7a/objs-debug/voiceenginejni/voice_engine_jni.o: In function `initVE':
/home/brian/workspace/VoiceEngineDemo/jni/voice_engine_jni.c:944: undefined reference to `VE_ADT_create'

It seem the link process is not loading the static module even though it is defined in the Android.mk as follows:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE               := voiceenginejni

LOCAL_SRC_FILES            := voice_engine_jni.c printing.c jaudio.c etime.c

LOCAL_CFLAGS               := -D __arm  -D ANDROID -D USE_AEC_DEFAULTS -D USE_EC_DEFAULTS -D _DEBUG -D EC_VARIANT=EC_VARIANT_NEC -D AECG1_5_ENABLE

LOCAL_STATIC_LIBRARIES     := libvoiceengine libcpufeatures libaecg2

LOCAL_LDLIBS               := -llog -ldl    

include $(BUILD_SHARED_LIBRARY)

$(call import-module,cpufeatures)    

The VE_ADT_create function is located in libvoiceengine.a, which has been placed in the /obj/local/armeabi-v7a/ directory.

I'd appreciate it if anyone can shed some light on this for me. Thanks!

Matthew
  • 44,826
  • 10
  • 98
  • 87
Brian
  • 53
  • 1
  • 5

1 Answers1

1

Are you building the libraries using ndk-build?

If not, I usually keep libraries I've built with the standalone toolchain in the jni folder and reference them directly by name in LOCAL_LDLIBS:

LOCAL_LDLIBS := libvoiceengine.a
Matthew
  • 44,826
  • 10
  • 98
  • 87
  • The static libraries are built using the "ndk-build" script, then the resulting .a are copied by a shell script into the /obj/local/armeabi-v7a/ directory. – Brian Mar 02 '11 at 21:49
  • hmm, another pitfall is accessing C functions from C++ without using extern "C" { ... } – Matthew Mar 02 '11 at 21:54
  • All of our code is C code. Curiously, the exact same project setup builds without issue using the NDK 4rb. – Brian Mar 02 '11 at 22:22