gpt4 book ai didi

Android C++ 应用程序在链接到共享库阶段崩溃

转载 作者:行者123 更新时间:2023-12-03 10:43:28 30 4
gpt4 key购买 nike

我有一个与许多 3rdpart 和自制库链接的 hello world C++ 应用程序。尝试加载它时它会立即崩溃,并出现段错误。
相同的代码,具有相同的依赖项,全部为 Linux 编译 - 成功运行。

我怎样才能开始调试它?
可能是什么原因?

编辑:这是 logcat 打印的内容:

F/libc    ( 8129): Fatal signal 11 (SIGSEGV), code 128, fault addr 0x0 in tid 8129 (HelloWorldApp) I/DEBUG   ( 2876): *** *** *** *** *** ***
*** *** *** *** *** *** *** *** *** *** I/DEBUG ( 2876): Build fingerprint: 'Intel/cht_hr/cht_hr:5.1.1/LMY47Z/LS0000037:userdebug/test-keys' I/DEBUG ( 2876): Revision: '0' W/NativeCrashListener( 3194): Couldn't find ProcessRecord for pid 8129 I/DEBUG ( 2876): ABI: 'x86' I/DEBUG ( 2876): pid: 8129, tid: 8129, name: HelloWorldApp >>> ./StaticImageOR <<< E/DEBUG ( 2876): AM write failure (32 / Broken pipe) I/DEBUG ( 2876): signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0 I/DEBUG ( 2876): eax ff84cadc ebx f32b7c6c ecx 00000010 edx 00000000 I/DEBUG ( 2876): esi f32c6610 edi 00000000 I/DEBUG ( 2876): xcs 00000023 xds 0000002b xes 0000002b xfs 00000000 xss 0000002b I/DEBUG ( 2876): eip f2600cfb ebp ff84c6dc esp ff84c5f4 flags 00010246 I/DEBUG ( 2876): I/DEBUG ( 2876): backtrace: I/DEBUG ( 2876): #00 pc 0062fcfb /system/lib/libcommander.so I/DEBUG ( 2876): #01 pc 0017651f /system/lib/libcommander.so I/DEBUG ( 2876): #02 pc 00001fcb /system/bin/linker (__dl__ZN6soinfo16CallConstructorsEv.part.23+1275) I/DEBUG ( 2876):
#03 pc 00001c26 /system/bin/linker (__dl__ZN6soinfo16CallConstructorsEv.part.23+342) I/DEBUG ( 2876):
#04 pc 00001c26 /system/bin/linker (__dl__ZN6soinfo16CallConstructorsEv.part.23+342) I/DEBUG ( 2876):
#05 pc 00008706 /system/bin/linker (__dl___linker_init+4998) I/DEBUG ( 2876): #06 pc 00009e0e /system/bin/linker (__dl__start+30) I/DEBUG ( 2876): I/DEBUG ( 2876): Tombstone written to: /data/tombstones/tombstone_02

所以我了解问题出在 libcommander 加载中。
如何继续这个?

谢谢!

最佳答案

最简单的方法是在调试器下运行你的应用程序,那么最近的 android studio 非常擅长调试 c++ 代码。有关如何调试 jni 代码的说明,请在 google code labs 中找到使用 Android Studio 创建 Hello-JNI .

其他解决方案是查看 logcat,您可能会发现崩溃的原因。例如,您可以找到类似的行

I/DEBUG   ( 8704): signal 11 (SIGSEGV), fault addr deadbaad
...
...

它将包含崩溃发生位置的调用堆栈。有了这些信息,您可以使用 ndk-stack - 工具(参见此处 ndk-stack),将帧地址转换为符号名称。

Android 会将其他可能帮助您找到问题位置的警告/jni 错误放入 logcat。

关于Android C++ 应用程序在链接到共享库阶段崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38565774/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com