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 分钟前
编程语言之战:AI 之后的 Kotlin 与 Java
android·java·开发语言·人工智能·kotlin
孤客网络科技工作室30 分钟前
AJAX 全面教程:从基础到高级
android·ajax·okhttp
Mr Lee_2 小时前
android 配置鼠标右键快捷对apk进行反编译
android
顾北川_野2 小时前
Android CALL关于电话音频和紧急电话设置和获取
android·音视频
&岁月不待人&2 小时前
Kotlin by lazy和lateinit的使用及区别
android·开发语言·kotlin
Winston Wood4 小时前
Android Parcelable和Serializable的区别与联系
android·序列化
清风徐来辽4 小时前
Android 项目模型配置管理
android
帅得不敢出门5 小时前
Gradle命令编译Android Studio工程项目并签名
android·ide·android studio·gradlew
problc5 小时前
Flutter中文字体设置指南:打造个性化的应用体验
android·javascript·flutter
帅得不敢出门16 小时前
安卓设备adb执行AT指令控制电话卡
android·adb·sim卡·at指令·电话卡