android移植dbus

前言

车载项目需要移植dbus到android系统中

移植

编译dbus源码
bash 复制代码
sudo apt-get install libtool

./autogen.sh
./configure --prefix=build
make
make install

移植错误汇总

bash 复制代码
fatal error: 'Windows.h' file not found 
解决:
apt-get install mingw-w64
bash 复制代码
No need to regenerate ninja file
Starting ninja...
FAILED: ninja: 'external/dbus-1.15.8/dbus/dbus-socket-set.c', needed by 'out/target/product/trinket/obj/SHARED_LIBRARIES/libdbus_intermediates/dbus-socket-set.o', missing and no known rule to make it
10:48:19 ninja failed with: exit status 1

最新的dbus 中dbus没有dbus-socket-set.c

bash 复制代码
No need to regenerate ninja file
Starting ninja...
FAILED: ninja: 'external/dbus-1.15.8/dbus/dbus-socket-set-poll.c', needed by 'out/target/product/trinket/obj/SHARED_LIBRARIES/libdbus_intermediates/dbus-socket-set-poll.o', missing and no known rule to make it
10:57:36 ninja failed with: exit status 1

最新的dbus 中dbus没有dbus-socket-set-poll.c

bash 复制代码
In file included from external/dbus-1.15.8/dbus/dbus-sha.c:27:
In file included from external/dbus-1.15.8/dbus/dbus-internals.h:33:
external/dbus-1.15.8/dbus/../dbus/dbus-types.h:33:10: fatal error: 'dbus/dbus-arch-deps.h' file not found
#include <dbus/dbus-arch-deps.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

将dbus编译生成的.h文件copy到dbus

bash 复制代码
external/dbus-1.15.8/dbus/dbus-sysdeps-unix.c:78:10: fatal error: 'execinfo.h' file not found
#include <execinfo.h>

解决:

bash 复制代码
config.h 中注释掉宏控
/* Define to 1 if you have backtrace(). */
//#define HAVE_BACKTRACE 1
bash 复制代码
ysdeps-unix.o external/dbus-1.15.8/dbus/dbus-sysdeps-unix.c"
external/dbus-1.15.8/dbus/dbus-sysdeps-unix.c:3016:31: error: use of undeclared identifier 'SYS_pidfd_open'
  int pid_fd = (int) syscall (SYS_pidfd_open, pid, 0);
                              ^
config.h中注释掉宏控
/* Define to 1 if you have the declaration of `SYS_pidfd_open', and to 0 if
   you don't. */
//#define HAVE_DECL_SYS_PIDFD_OPEN 1
bash 复制代码
external/dbus-1.15.8/dbus/dbus-internals.c:183:1: error: '_assertion' declared as an array with a negative size
_DBUS_STATIC_ASSERT (sizeof (void *) == DBUS_SIZEOF_VOID_P);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/dbus-1.15.8/dbus/../dbus/dbus-internals.h:485:36: note: expanded from macro '_DBUS_STATIC_ASSERT'
  typedef struct { char _assertion[(expr) ? 1 : -1]; } \
                                   ^~~~~~~~~~~~~~~
1 error generated.

dbus-internals.h 修改
#define _DBUS_STATIC_ASSERT(expr) \
  typedef struct { char _assertion[(expr) ? 1 :0]; } \
  _DBUS_PASTE (_DBUS_STATIC_ASSERT_, __LINE__) _DBUS_GNUC_UNUSED
bash 复制代码
external/dbus-1.15.8/dbus/dbus-marshal-basic.c:1683:30: error: implicit conversion from 'long long' to 'dbus_int64_t' (aka 'long') changes value from 1254130450431 to -1 [-Werror,-Wconstant-conversion]
  dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff),
                           ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/dbus-1.15.8/dbus/../dbus/dbus-arch-deps.h:41:58: note: expanded from macro 'DBUS_INT64_CONSTANT'
#define DBUS_INT64_CONSTANT(val)  (_DBUS_GNUC_EXTENSION (val##L))
                                                         ^~~~~~
<scratch space>:106:1: note: expanded from here
0x123ffffffffL
^~~~~~~~~~~~~~

:: Android.mk 修改
LOCAL_CFLAGS += -Wno-constant-conversion
bash 复制代码
roid_arm64_armv8-a_kryo300_core/obj/bionic/libc/arch-common/bionic/crtend_so.o"
ld.lld: error: undefined symbol: _dbus_pollable_set_epoll_new
>>> referenced by dbus-pollable-set.c:37 (external/dbus-1.15.8/dbus/dbus-pollable-set.c:37)
>>>               out/target/product/trinket/obj/SHARED_LIBRARIES/libdbus_intermediates/dbus-pollable-set.o:(_dbus_pollable_set_new)

ld.lld: error: undefined symbol: _dbus_pollable_set_poll_new
>>> referenced by dbus-pollable-set.c:43 (external/dbus-1.15.8/dbus/dbus-pollable-set.c:43)
>>>               out/target/product/trinket/obj/SHARED_LIBRARIES/libdbus_intermediates/dbus-pollable-set.o:(_dbus_pollable_set_new)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Android.mk 修改:
添加dbus-pollable-set-epoll.c
bash 复制代码
external/dbus-1.15.8/bus/selinux.c:48:10: fatal error: 'selinux/selinux.h' file not found
#include <selinux/selinux.h>
         ^~~~~~~~~~~~~~~~~~~
/* SELinux support */
#define HAVE_SELINUX 1

待续

相关推荐
拭心8 小时前
Google 提供的 Android 端上大模型组件:MediaPipe LLM 介绍
android
带电的小王10 小时前
WhisperKit: Android 端测试 Whisper -- Android手机(Qualcomm GPU)部署音频大模型
android·智能手机·whisper·qualcomm
梦想平凡11 小时前
PHP 微信棋牌开发全解析:高级教程
android·数据库·oracle
元争栈道11 小时前
webview和H5来实现的android短视频(短剧)音视频播放依赖控件
android·音视频
阿甘知识库12 小时前
宝塔面板跨服务器数据同步教程:双机备份零停机
android·运维·服务器·备份·同步·宝塔面板·建站
元争栈道12 小时前
webview+H5来实现的android短视频(短剧)音视频播放依赖控件资源
android·音视频
MuYe13 小时前
Android Hook - 动态加载so库
android
居居飒13 小时前
Android学习(四)-Kotlin编程语言-for循环
android·学习·kotlin
Henry_He16 小时前
桌面列表小部件不能点击的问题分析
android
工程师老罗16 小时前
Android笔试面试题AI答之Android基础(1)
android