Mazyod Mazyod - 5 months ago 57
Android Question

Compiling C library for android, but no symbols found

I am trying to compile a simple C library for android, but the resulting library doesn't contain any symbols/objects! I am checking the library using

nm
command.

This is the Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := my_lib_static
LOCAL_MODULE_FILENAME := libmylib

LOCAL_C_INCLUDES := $(LOCAL_PATH)

LOCAL_SRC_FILES := File1.c File2.c

include $(BUILD_SHARED_LIBRARY)
# or include $(BUILD_STATIC_LIBRARY)


EDIT:

A subfolder called "objs" is created, which has all the symbols.

EDIT:

This is the output of
gobjdump
:

MyLibBot.o: file format elf32-littlemips

gobjdump: MyLibBot.o: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols



MyLibCommon.o: file format elf32-littlemips

gobjdump: MyLibCommon.o: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols



MyLibGameLogic.o: file format elf32-littlemips

gobjdump: MyLibGameLogic.o: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols



MyLibUndoStack.o: file format elf32-littlemips

gobjdump: MyLibUndoStack.o: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols

Answer

You have to specify the -D flag to nm if you want it to display dynamic symbols.

You can also use the -T flag to objdump

You should use the versions of nm or objdump provided in the ndk, not any versions which might be found for managing libraries of the development host. These will be found buried far under the toolchains/ folder of the ndk and will have prefixed names something like arm-linux-androideabi-nm

For example, (on a system I haven't used for Android work in a while, so containing a stale version - you will have to use some ingenuity to find what is applicable on your system):

$NDK/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm -D mylibrary.so