为 android 编译 C 库,但未找到符号 [英] Compiling C library for android, but no symbols found

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

问题描述

我正在尝试为 android 编译一个简单的 C 库,但生成的库不包含任何符号/对象!我正在使用 nm 命令检查库.

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.

这是 Android.mk:

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)

编辑:

创建了一个名为objs"的子文件夹,其中包含所有符号.

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

编辑:

这是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

推荐答案

如果你想让nm显示动态符号,你必须指定-D标志.

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

您也可以使用 -T 标志来进行 objdump

You can also use the -T flag to objdump

您应该使用 ndk 中提供的 nm 或 objdump 版本,而不是任何可能用于管理开发主机库的版本.这些将被埋在 ndk 的 toolchains/文件夹下很远,并且会带有前缀名称,例如 arm-linux-androideabi-nm

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

例如,(在我有一段时间没有用于 Android 工作的系统上,因此包含一个过时的版本 - 你将不得不使用一些独创性来找到适用于你的系统的内容):

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

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

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