当前位置:   article > 正文

【android9.0】system/core下的usbhost模块无法输出log到logcat

android.bp依赖lpthread

现象:原生android9.0 sdk,system/core/libusbhost是usb模块用来和驱动通信的模块,在调试时希望能输出log到logcat,打开调试开关重新编译代码,报“undefined reference to '__android_log_print'”错误

  1. FAILED: out/soong/.intermediates/system/core/libusbhost/libusbhost/linux_glibc_x86_64_shared/libusbhost.so
  2. prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ @out/soong/.intermediates/system/core/libusbhost/libusbhost/linux_glibc_x86_64_shared/libusbhost.so.rsp out/soong/.intermediates/external/compiler-rt/libcompiler_rt-extras/linux_glibc_x86_64_static/libcompiler_rt-extras.a out/soong/.intermediates/external/libcxx/libc++/linux_glibc_x86_64_shared/libc++.so -o out/soong/.intermediates/system/core/libusbhost/libusbhost/linux_glibc_x86_64_shared/libusbhost.so -shared -Wl,-soname,libusbhost.so -target x86_64-linux-gnu -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined-version --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -m64 -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/lib/gcc/x86_64-linux/4.8 -Lprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/lib/gcc/x86_64-linux/4.8 -Lprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/lib64 -ldl -lpthread -lm -lrt -Wl,-rpath,\$ORIGIN/../lib64 -Wl,-rpath,\$ORIGIN/lib64 -nodefaultlibs -lgcc_s -lgcc -lc -lgcc_s -lgcc
  3. system/core/libusbhost/usbhost.c:211: error: undefined reference to '__android_log_print'
  4. system/core/libusbhost/usbhost.c:278: error: undefined reference to '__android_log_print'
  5. system/core/libusbhost/usbhost.c:301: error: undefined reference to '__android_log_print'
  6. system/core/libusbhost/usbhost.c:305: error: undefined reference to '__android_log_print'
  7. clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
  8. [ 16% 97/605] Construct recovery from boot
  9. ninja: build stopped: subcommand failed.
  10. 11:04:39 ninja failed with: exit status 1

问题原因:

此问题的根本原因是,编译系统在链接时找不到相应的函数实现体,与头文件缺失无关,即函数实现体所在的liblog库无法被找到

解决办法:修改Android.bp,将liblog共享库声明放在target外面,暂不清楚放target里边为什么会链接不到

  1. diff --git a/libusbhost/Android.bp b/libusbhost/Android.bp
  2. old mode 100644
  3. new mode 100755
  4. index fc6f305..43076eb
  5. --- a/libusbhost/Android.bp
  6. +++ b/libusbhost/Android.bp
  7. @@ -24,13 +24,16 @@ cc_library {
  8. srcs: ["usbhost.c"],
  9. cflags: ["-Werror"],
  10. export_include_dirs: ["include"],
  11. + shared_libs: [
  12. + "liblog",
  13. + ],
  14. target: {
  15. android: {
  16. cflags: [
  17. "-g",
  18. "-DUSE_LIBLOG",
  19. ],
  20. - shared_libs: ["liblog"],
  21. + //shared_libs: ["liblog"],
  22. },
  23. darwin: {
  24. enabled: false,

 

转载于:https://my.oschina.net/u/3750358/blog/3049783

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/674538
推荐阅读
相关标签
  

闽ICP备14008679号