编译C库为Android,但没有发现符号 [英] Compiling C library for android, but no symbols found

查看:486
本文介绍了编译C库为Android,但没有发现符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译一个简单的C库为Android,但由此产生的库不包含任何符号/对象!我使用纳米命令检查库。

这是Android.mk:

  LOCAL_PATH:= $(叫我-DIR)
包括$(CLEAR_VARS)LOCAL_MODULE:= my_lib_static
LOCAL_MODULE_FILENAME:=的libmylibLOCAL_C_INCLUDES:= $(LOCAL_PATH)LOCAL_SRC_FILES:= FILE1.C file2.c中包括$(BUILD_SHARED_LIBRARY)
#或包含$(BUILD_STATIC_LIBRARY)

修改

所谓的OBJ文件中创建子文件夹,里面有所有的符号。

修改

这是输出 gobjdump

  MyLibBot.o:文件格式ELF32-littlemipsgobjdump:MyLibBot.o:不是一个动态对象
动态符号表:
无符号MyLibCommon.o:文件格式ELF32-littlemipsgobjdump:MyLibCommon.o:不是一个动态对象
动态符号表:
无符号MyLibGameLogic.o:文件格式ELF32-littlemipsgobjdump:MyLibGameLogic.o:不是一个动态对象
动态符号表:
无符号MyLibUndoStack.o:文件格式ELF32-littlemipsgobjdump:MyLibUndoStack.o:不是一个动态对象
动态符号表:
无符号


解决方案

您,如果您希望它显示动态符号指定-D标志,以纳米。

您也可以使用-T标志objdump的

您应该使用纳米的版本或objdump的在NDK提供的,没有可能用于管理开发主机库中找到的任何版本。这些将被发现埋在NDK的远低于工具链/文件夹,将有prefixed名类似 ARM-Linux的androideabi纳米

例如,(在系统上我没有使用过Android的工作一段时间,所以含陈旧版本 - 你将不得不使用一些别出心裁地找到您的系统上有什么适用):

<$p$p><$c$c>$NDK/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/linux-x86/bin/arm-linux-androideabi-nm -D mylibrary.so

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

解决方案

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

这篇关于编译C库为Android,但没有发现符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆