03-SA8155 QNX 交叉编译环境

1. 背景

很多程序不需要,也不希望在Source code环境下编译,想单独拉出来编译,这个时候需要QNX SDK ToolChains(交叉编译工具链)。将此工具链单独抽离出来,在WINDOWS以及Linux等开发环境下进行软件开发,比如第三方库,中间件开发,APP开发等,便于快速编译验证。

03-SA8155 QNX 交叉编译环境_第1张图片

2. 交叉编译工具链

QNX 700的工具链为:prebuilt_QNX700

SA8155 QNX工具链路径:qnx_ap/qnx_bins/prebuilt_QNX700

查看qnx_ap/qnx_bins/prebuilt_QNX700/host/linux/x86_64/usr/bin目录下文件:

tree -L 1

├── aarch64-unknown-nto-qnx7.0.0-addr2line
├── aarch64-unknown-nto-qnx7.0.0-addr2line-2.25
├── aarch64-unknown-nto-qnx7.0.0-ar
├── aarch64-unknown-nto-qnx7.0.0-ar-2.25
├── aarch64-unknown-nto-qnx7.0.0-as
├── aarch64-unknown-nto-qnx7.0.0-as-2.25
├── aarch64-unknown-nto-qnx7.0.0-c++
├── aarch64-unknown-nto-qnx7.0.0-c++-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-c++filt
├── aarch64-unknown-nto-qnx7.0.0-c++filt-2.25
├── aarch64-unknown-nto-qnx7.0.0-cpp
├── aarch64-unknown-nto-qnx7.0.0-cpp-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-dwp
├── aarch64-unknown-nto-qnx7.0.0-dwp-2.25
├── aarch64-unknown-nto-qnx7.0.0-elfedit
├── aarch64-unknown-nto-qnx7.0.0-elfedit-2.25
├── aarch64-unknown-nto-qnx7.0.0-g++
├── aarch64-unknown-nto-qnx7.0.0-g++-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcc
├── aarch64-unknown-nto-qnx7.0.0-gcc-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcc-ar
├── aarch64-unknown-nto-qnx7.0.0-gcc-ar-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcc-nm
├── aarch64-unknown-nto-qnx7.0.0-gcc-nm-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcc-ranlib
├── aarch64-unknown-nto-qnx7.0.0-gcc-ranlib-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcov
├── aarch64-unknown-nto-qnx7.0.0-gcov-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gcov-tool
├── aarch64-unknown-nto-qnx7.0.0-gcov-tool-5.4.0
├── aarch64-unknown-nto-qnx7.0.0-gprof
├── aarch64-unknown-nto-qnx7.0.0-gprof-2.25
├── aarch64-unknown-nto-qnx7.0.0-ld
├── aarch64-unknown-nto-qnx7.0.0-ld-2.25
├── aarch64-unknown-nto-qnx7.0.0-ld.bfd
├── aarch64-unknown-nto-qnx7.0.0-ld.bfd-2.25
├── aarch64-unknown-nto-qnx7.0.0-ld.gold
├── aarch64-unknown-nto-qnx7.0.0-ld.gold-2.25
├── aarch64-unknown-nto-qnx7.0.0-nm
├── aarch64-unknown-nto-qnx7.0.0-nm-2.25
├── aarch64-unknown-nto-qnx7.0.0-objcopy
├── aarch64-unknown-nto-qnx7.0.0-objcopy-2.25
├── aarch64-unknown-nto-qnx7.0.0-objdump
├── aarch64-unknown-nto-qnx7.0.0-objdump-2.25
├── aarch64-unknown-nto-qnx7.0.0-ranlib
├── aarch64-unknown-nto-qnx7.0.0-ranlib-2.25
├── aarch64-unknown-nto-qnx7.0.0-readelf
├── aarch64-unknown-nto-qnx7.0.0-readelf-2.25
├── aarch64-unknown-nto-qnx7.0.0-size
├── aarch64-unknown-nto-qnx7.0.0-size-2.25
├── aarch64-unknown-nto-qnx7.0.0-strings
├── aarch64-unknown-nto-qnx7.0.0-strings-2.25
├── aarch64-unknown-nto-qnx7.0.0-strip
├── aarch64-unknown-nto-qnx7.0.0-strip-2.25
├── addvariant
├── arm-unknown-nto-qnx7.0.0eabi-addr2line
├── arm-unknown-nto-qnx7.0.0eabi-addr2line-2.25
├── arm-unknown-nto-qnx7.0.0eabi-ar
├── arm-unknown-nto-qnx7.0.0eabi-ar-2.25
├── arm-unknown-nto-qnx7.0.0eabi-as
├── arm-unknown-nto-qnx7.0.0eabi-as-2.25
├── arm-unknown-nto-qnx7.0.0eabi-c++
├── arm-unknown-nto-qnx7.0.0eabi-c++-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-c++filt
├── arm-unknown-nto-qnx7.0.0eabi-c++filt-2.25
├── arm-unknown-nto-qnx7.0.0eabi-cpp
├── arm-unknown-nto-qnx7.0.0eabi-cpp-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-dwp
├── arm-unknown-nto-qnx7.0.0eabi-dwp-2.25
├── arm-unknown-nto-qnx7.0.0eabi-elfedit
├── arm-unknown-nto-qnx7.0.0eabi-elfedit-2.25
├── arm-unknown-nto-qnx7.0.0eabi-g++
├── arm-unknown-nto-qnx7.0.0eabi-g++-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcc
├── arm-unknown-nto-qnx7.0.0eabi-gcc-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcc-ar
├── arm-unknown-nto-qnx7.0.0eabi-gcc-ar-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcc-nm
├── arm-unknown-nto-qnx7.0.0eabi-gcc-nm-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcc-ranlib
├── arm-unknown-nto-qnx7.0.0eabi-gcc-ranlib-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcov
├── arm-unknown-nto-qnx7.0.0eabi-gcov-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gcov-tool
├── arm-unknown-nto-qnx7.0.0eabi-gcov-tool-5.4.0
├── arm-unknown-nto-qnx7.0.0eabi-gprof
├── arm-unknown-nto-qnx7.0.0eabi-gprof-2.25
├── arm-unknown-nto-qnx7.0.0eabi-ld
├── arm-unknown-nto-qnx7.0.0eabi-ld-2.25
├── arm-unknown-nto-qnx7.0.0eabi-ld.bfd
├── arm-unknown-nto-qnx7.0.0eabi-ld.bfd-2.25
├── arm-unknown-nto-qnx7.0.0eabi-ld.gold
├── arm-unknown-nto-qnx7.0.0eabi-ld.gold-2.25
├── arm-unknown-nto-qnx7.0.0eabi-nm
├── arm-unknown-nto-qnx7.0.0eabi-nm-2.25
├── arm-unknown-nto-qnx7.0.0eabi-objcopy
├── arm-unknown-nto-qnx7.0.0eabi-objcopy-2.25
├── arm-unknown-nto-qnx7.0.0eabi-objdump
├── arm-unknown-nto-qnx7.0.0eabi-objdump-2.25
├── arm-unknown-nto-qnx7.0.0eabi-ranlib
├── arm-unknown-nto-qnx7.0.0eabi-ranlib-2.25
├── arm-unknown-nto-qnx7.0.0eabi-readelf
├── arm-unknown-nto-qnx7.0.0eabi-readelf-2.25
├── arm-unknown-nto-qnx7.0.0eabi-size
├── arm-unknown-nto-qnx7.0.0eabi-size-2.25
├── arm-unknown-nto-qnx7.0.0eabi-strings
├── arm-unknown-nto-qnx7.0.0eabi-strings-2.25
├── arm-unknown-nto-qnx7.0.0eabi-strip
├── arm-unknown-nto-qnx7.0.0eabi-strip-2.25
├── ntoaarch64-addr2line
├── ntoaarch64-addr2line-2.25
├── ntoaarch64-ar
├── ntoaarch64-ar-2.25
├── ntoaarch64-as
├── ntoaarch64-as-2.25
├── ntoaarch64-c++
├── ntoaarch64-c++-5.4.0
├── ntoaarch64-c++filt
├── ntoaarch64-c++filt-2.25
├── ntoaarch64-cpp
├── ntoaarch64-cpp-5.4.0
├── ntoaarch64-dwp
├── ntoaarch64-dwp-2.25
├── ntoaarch64-elfedit
├── ntoaarch64-elfedit-2.25
├── ntoaarch64-g++
├── ntoaarch64-g++-5.4.0
├── ntoaarch64-gcc
├── ntoaarch64-gcc-5.4.0
├── ntoaarch64-gcc-ar
├── ntoaarch64-gcc-ar-5.4.0
├── ntoaarch64-gcc-nm
├── ntoaarch64-gcc-nm-5.4.0
├── ntoaarch64-gcc-ranlib
├── ntoaarch64-gcc-ranlib-5.4.0
├── ntoaarch64-gcov
├── ntoaarch64-gcov-5.4.0
├── ntoaarch64-gcov-tool
├── ntoaarch64-gcov-tool-5.4.0
├── ntoaarch64-gdb
├── ntoaarch64-gprof
├── ntoaarch64-gprof-2.25
├── ntoaarch64-ld
├── ntoaarch64-ld-2.25
├── ntoaarch64-ld.bfd
├── ntoaarch64-ld.bfd-2.25
├── ntoaarch64-ld.gold
├── ntoaarch64-ld.gold-2.25
├── ntoaarch64-nm
├── ntoaarch64-nm-2.25
├── ntoaarch64-objcopy
├── ntoaarch64-objcopy-2.25
├── ntoaarch64-objdump
├── ntoaarch64-objdump-2.25
├── ntoaarch64-ranlib
├── ntoaarch64-ranlib-2.25
├── ntoaarch64-readelf
├── ntoaarch64-readelf-2.25
├── ntoaarch64-size
├── ntoaarch64-size-2.25
├── ntoaarch64-strings
├── ntoaarch64-strings-2.25
├── ntoaarch64-strip
├── ntoaarch64-strip-2.25

根据需要有很多工具链可以选择。

3. 脚本

一个C代码的编译需要:编译工具(GCC),参数,链接库,头文件等

那么我们可以对此着手

环境配置:

QNX_PREBUILT=/workspace/SA8155_PJ/qnx_ap/qnx_bins/prebuilt_QNX700
export QNX_TARGET=$QNX_PREBUILT/target/qnx7
export QNX_HOST=$QNX_PREBUILT/host/linux/x86_64
export MAKEFLAGS=-I$QNX_PREBUILT/target/qnx7/usr/include
export MAKELDFLAGS=-L$QNX_PREBUILT/target/qnx7/usr/lib,-L$QNX_PREBUILT/target/qnx7/aarch64le/lib
export QNX_CC=$QNX_PREBUILT/host/linux/x86_64/usr/bin/ntoaarch64-gcc

很多gcc配置,不一一说明。 

编译及输出: 

${QNX_CC} test.c ${MAKEFLAGS} ${MAKELDFLAGS} -lxxx -lstatic -o test

  • -l(小写的L) ,后面跟库的名称,static就是libstatic.a 的名称
  • -L —>指定库文件的路径,加路径时可空格,也可不空格
  • -I —>指定头文件的路径,加路径时可空格,也可不空格

4. 实操

TODO 

你可能感兴趣的:(SA8155P平台开发,QNX,交叉编译,aarch64,SA8155,prebuilt_QNX700,QNX,工具链)