Compiling C library for android, but no symbols found(为 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 库,但未找到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为 android 编译 C 库,但未找到符号


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01