fdbus 可以这讲,就是一个定制化的RPC,可以用于进程间通信,以及双系统间通信。
TODO
fdbus镜像地址:fdbus
Android ndk下载:Android ndk
QNX tools下载: prebuilt_QNX700
下载完,解压!
TODO
废话不多数,直接上编译脚本
build_qnx.sh
#!/bin/sh
###################################
#### build script for fdbus
#### taget:qnx
#### Date: 2022-11-01
#### Author: 村里小码农
###################################
# qnx tools dir
QNX_TOOLS_PATH=/workspace/tools/prebuilt_QNX700
# current dir
CURRENT_PATH=$(pwd)
PREFIX=$CURRENT_PATH/build/qnx/install
PROTOBUF=$CURRENT_PATH/../protobuf-3.20.2
mkdir -p $PREFIX
export QNX_CONFIGURATION=$QNX_TOOLS_PATH/.qnx
export QNX_TARGET=$QNX_TOOLS_PATH/target/qnx7
export QNX_HOST=$QNX_TOOLS_PATH/host/linux/x86_64
export MAKEFLAGS=-I$QNX_TOOLS_PATH/target/qnx7/usr/include
export MAKELDFLAGS=-L$QNX_TOOLS_PATH/target/qnx7/usr/lib,-L$QNX_PREBUILT/target/qnx7/aarch64le/lib
#QNX_TOOLCHAINS_CC64=$QNX_TOOLS_PATH/host/linux/x86_64/usr/bin/ntoaarch64-gcc
#QNX_TOOLCHAINS_CXX64=$QNX_TOOLS_PATH/host/linux/x86_64/usr/bin/ntoaarch64-g++
#use aarch64-unknown-nto-qnx7.0.0
QNX_TOOLCHAINS_CC64=$QNX_TOOLS_PATH/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc
QNX_TOOLCHAINS_CXX64=$QNX_TOOLS_PATH/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
export PATH=$PROTOBUF/build/qnx/install/bin:$PATH
export LD_LIBRARY_PATH=$PROTOBUF/build/qnx/install/lib:$LD_LIBRARY_PATH
cd $CURRENT_PATH/build/qnx/
echo "---------------------------"
echo " > start to build fdbus."
echo "---------------------------"
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DSYSTEM_ROOT=$PROTOBUF/build/qnx/install \
-DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain.cmake \
-Dfdbus_QNX=ON \
-Dfdbus_LOG_TO_STDOUT=ON \
-Dfdbus_SOCKET_ENABLE_PEERCRED=OFF \
-Dfdbus_PIPE_AS_EVENTFD=ON \
-Dfdbus_LINK_SOCKET_LIB=ON \
-Dfdbus_SOCKET_QNX_PEERCRED=ON \
-Dfdbus_QNX_DIRENT=ON \
-Dfdbus_QNX_KEEPALIVE=ON \
-Dfdbus_CONFIG_NO_IFADDR=ON \
-Dfdbus_LINK_PTHREAD_LIB=OFF \
../../cmake
#-DSYSTEM_ROOT=$PROTOBUF/out/qnx/
# -Dfdbus_QNX_KEEPALIVE=ON
# -Dfdbus_SOCKET_QNX_PEERCRED=ON
# -DCMAKE_CXX_FLAGS='-O2 -g -Os -Wall -fstack-protector-strong -DGOOGLE_PROTOBUF_ARCH_64_BIT'
# -DCMAKE_C_FLAGS='-O2 -g -Os -Wall -fstack-protector-strong'
make
make install
echo "---------------------------"
echo " > build finished."
echo "---------------------------"
cd ${CURRENT_PATH}
修改 cmake/toolschain.cmake
SET(CMAKE_SYSTEM_NAME qnx)
SET(QNX_TOOLS_PATH /workspace/tools/prebuilt_QNX700)
SET(CMAKE_CXX_COMPILER ${QNX_TOOLS_PATH}/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++)
SET(CMAKE_C_COMPILER ${QNX_TOOLS_PATH}/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc)
编译成功:
── qnx
├── CMakeCache.txt
├── CMakeFiles
│ ├── 3.16.3
│ ├── cmake.check_cache
│ ├── CMakeDirectoryInformation.cmake
│ ├── CMakeOutput.log
│ ├── CMakeRuleHashes.txt
│ ├── CMakeTmp
│ ├── common_base.dir
│ ├── fdbus-clib.dir
│ ├── fdbxclient.dir
│ ├── fdbxserver.dir
│ ├── host_server.dir
│ ├── logsvc.dir
│ ├── logviewer.dir
│ ├── lsclt.dir
│ ├── lsevt.dir
│ ├── lshost.dir
│ ├── lssvc.dir
│ ├── Makefile2
│ ├── Makefile.cmake
│ ├── name_server.dir
│ ├── ntfcenter.dir
│ ├── progress.marks
│ ├── TargetDirectories.txt
│ └── uninstall.dir
├── cmake_install.cmake
├── cmake_uninstall.cmake
├── fdbxclient
├── fdbxserver
├── host_server
├── install
│ └── usr
├── install_manifest.txt
├── libcommon_base.so
├── libfdbus-clib.so
├── logsvc
├── logviewer
├── lsclt
├── lsevt
├── lshost
├── lssvc
├── Makefile
├── name_server
└── ntfcenter
build_android.sh
#!/bin/sh
###################################
#### build script for protobuf
#### taget:qnx
#### Date: 2022-11-01
#### Author: 村里小码农
###################################
# qnx bsp dir
NDKROOT_PATH=/workspace/tools/android-ndk-r23b
TOOLCHAIN=$NDKROOT_PATH/toolchains/llvm/prebuilt/linux-x86_64
# current dir
CURRENT_PATH=$(pwd)
# config Compile param.
TARGET_API=28
#
TARGET_ANDROID_PLATFORM=android-$TARGET_API
#预留
TARGET=aarch64-linux-android
#TARGET_ABI=armeabi-v7a
TARGET_ABI=arm64-v8a
PREFIX=$CURRENT_PATH/build/android/install
PROTOBUF=$CURRENT_PATH/../protobuf-3.20.2
export PATH=$PROTOBUF/build/android/install/bin:$PATH
export LD_LIBRARY_PATH=$PROTOBUF/build/android/install/lib:$LD_LIBRARY_PATH
if [ -d $PREFIX ];then
rm -rf $PREFIX
mkdir -p $PREFIX
else
mkdir -p $PREFIX
fi
if [ ! -f $TOOLCHAIN/bin/$TARGET$TARGET_API-ar ];then
ln -s $TOOLCHAIN/bin/llvm-ar $TOOLCHAIN/bin/$TARGET$TARGET_API-ar
fi
if [ ! -f $TOOLCHAIN/bin/$TARGET$TARGET_API-nm ];then
ln -s $TOOLCHAIN/bin/llvm-nm $TOOLCHAIN/bin/$TARGET$TARGET_API-nm
fi
if [ ! -f $TOOLCHAIN/bin/$TARGET$TARGET_API-ranlib ];then
ln -s $TOOLCHAIN/bin/llvm-ar $TOOLCHAIN/bin/$TARGET$TARGET_API-ranlib
fi
echo "---------------------------"
echo " > start to build ARM64."
echo "---------------------------"
cd $CURRENT_PATH/build/android
cmake -DCMAKE_TOOLCHAIN_FILE=$NDKROOT_PATH/build/cmake/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DSYSTEM_ROOT=$PROTOBUF/build/android/install \
-DANDROID_ABI=$TARGET_ABI \
-DANDROID_NATIVE_API_LEVEL=$TARGET_API \
-DCMAKE_BUILD_TYPE=Release\
-DANDROID_TOOLCHAIN=clang \
-Dfdbus_ANDROID=ON \
-Dfdbus_LOG_TO_STDOUT=ON \
-Dfdbus_CONFIG_NO_IFADDR=ON \
-Dfdbus_LINK_PTHREAD_LIB=OFF \
../../cmake/
make
make install
echo "---------------------------"
echo " > build finished."
echo "---------------------------"
cd $CURRENT_PATH
如上,但是ndk编译会报错。 //如下信息
ld: error: undefined symbol: __android_log_print
>>> referenced by CBaseClient.cpp:101.....
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/common_base.dir/build.make:533: recipe for target 'libcommon_base.so' failed
make[2]: *** [libcommon_base.so] Error 1
CMakeFiles/Makefile2:262: recipe for target 'CMakeFiles/common_base.dir/all' failed
make[1]: *** [CMakeFiles/common_base.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
没关系,一看是缺少链接库log导致的
那么修改cmake/CMakeLists.txt
增加如下code:
if(fdbus_ANDROID)
link_libraries(log)
endif()
再次编译:
./build_android.sh
编译OK
├── android
│ ├── arm64-v8a
│ │ └── usr
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ │ ├── 3.16.3
│ │ ├── cmake.check_cache
│ │ ├── CMakeDirectoryInformation.cmake
│ │ ├── CMakeOutput.log
│ │ ├── CMakeRuleHashes.txt
│ │ ├── CMakeTmp
│ │ ├── common_base.dir
│ │ ├── fdbus-clib.dir
│ │ ├── fdbxclient.dir
│ │ ├── fdbxserver.dir
│ │ ├── host_server.dir
│ │ ├── logsvc.dir
│ │ ├── logviewer.dir
│ │ ├── lsclt.dir
│ │ ├── lsevt.dir
│ │ ├── lshost.dir
│ │ ├── lssvc.dir
│ │ ├── Makefile2
│ │ ├── Makefile.cmake
│ │ ├── name_server.dir
│ │ ├── ntfcenter.dir
│ │ ├── progress.marks
│ │ ├── TargetDirectories.txt
│ │ └── uninstall.dir
│ ├── cmake_install.cmake
│ ├── cmake_uninstall.cmake
│ ├── fdbxclient
│ ├── fdbxserver
│ ├── host_server
│ ├── install_manifest.txt
│ ├── libcommon_base.so
│ ├── libfdbus-clib.so
│ ├── logsvc
│ ├── logviewer
│ ├── lsclt
│ ├── lsevt
│ ├── lshost
│ ├── lssvc
│ ├── Makefile
│ ├── name_server
│ └── ntfcenter