简体   繁体   中英

JNI Static Library Failing to Link

I am trying to debug some link errors I am getting when building the C++ side of my app. The Android.mk looks as follows:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := GLES
LOCAL_SRC_FILES := ModelGLES.cpp RendererGLES.cpp
LOCAL_LDLIBS    := -llog -lGLESv1_CM
LOCAL_LDFLAGS   := -Wl,-Map,$(LOCAL_MODULE).map 

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := SndSys
LOCAL_SRC_FILES := SndSys.cpp libaudio_wrapper.cpp
LOCAL_STATIC_LIBRARIES := libaudio_ARM_NDK
LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS   := -Wl,-Map,$(LOCAL_MODULE).map 
LOCAL_C_INCLUDES := $(LOCAL_PATH)

include $(BUILD_SHARED_LIBRARY)

The error I am getting is with libaudio_wrapper. The linker can't resole the symbols in libaudio_ARM_NDK. The folder structure looks as follows:

App\\ jni\\ SndSys.cpp libaudio_wrapper.cpp Android.mk libaudio_ARM_NDK.a

I am calling ndk-build form inside the jni folder. The output is as follows:

Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : GLES <= ModelGLES.cpp
Compile++ thumb  : GLES <= RendererGLES.cpp
SharedLibrary  : libGLES.so
Install        : libGLES.so => libs/armeabi/libGLES.so
Compile++ thumb  : SndSys <= SndSys.cpp
Compile++ thumb  : SndSys <= libaudio_wrapper.cpp
SharedLibrary  : libSndSys.so
/Users/bob/Desktop/Root/Relaxation/obj/local/armeabi/objs-debug/SndSys/libaudio_wrapper.o: In function `audioInit(int, int)':
/Users/bob/Desktop/Root/Relaxation/jni/libaudio_wrapper.cpp:37: undefined reference to `GetAudioChannelSize'
/Users/bob/Desktop/Root/Relaxation/jni/libaudio_wrapper.cpp:38: undefined reference to `GetAudioInitControlSize'

Is there an easy way to see if the linker is finding my library? Or to get the command line calls to gcc or ld?

The problem was I had upgraded to the ndk-r5. Some of the rules for building Prebuilt libraries had changed. Each pre-built library needs its own Module set aside for it. The second half of the Android.ml should look like this...

include $(CLEAR_VARS)

LOCAL_MODULE := audiolib
LOCAL_SRC_FILES := libaudio_ARM_NDK.a

include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)

LOCAL_MODULE    := SndSys
LOCAL_SRC_FILES := SndSys.cpp libaduio_wrapper.cpp
LOCAL_STATIC_LIBRARIES := audiolib
LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM