how to use cmake crosscompiler/running arm on x86_64 ubuntu

原创
2022/08/11 15:28
阅读数 118

1、check object machine wordsize、biglittleend、abitype
CM must be same with OM。

gcc-arm-linux-gnueabi – The GNU C compiler for armel architecture
gcc-arm-linux-gnueabihf – The GNU C compiler for armhf architecture

2、check useful gcc version ,down it
c++98、11、14、17
http://c.biancheng.net/view/8053.html

https://releases.linaro.org/components/toolchain/binaries/

3、touch arm.cmake file for adapter cmake

########
set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_SYSTEM_PROCESSOR arm)
# which compilers to use for C and C++

set(tools /usr/local/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin)
set(CMAKE_C_COMPILER ${tools}/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${tools}/arm-linux-gnueabihf-g++)

# Name of archiving tool for static libraries
set(CMAKE_AR ${tools}/arm-linux-gnueabihf-ar CACHE PATH "ARM Linux ar Program")

# where is the target environment located
set(CMAKE_FIND_ROOT_PATH <third-party library install path>
    /usr/local/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/
    /usr/local/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf
)

#set(CMAKE_LIBRARY_PATH /home/ARMLIBS
#  )

# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
########


4、cmake-gui--configure-specify toolchain file for cross-compiling,choose arm.cmake

if sourcecode dependency libs could find on gcc-arm-linux-gnueabi env,U can just build 2 die
else U must build all dependency libs recursion until arm ENV include alllibs。

5、running on X86 by qemu

qemu-arm-static -L /usr/local/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/libc/ ServiceMain "111111"

why must add this step,because save fix debug time

 

6、Running on OM/arm
compress arm toolchain on OM
export LD_LIBRARY_PATH=:/opt/gcc-8/lib:$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
copy exec program dependency all libs on OM
running test


 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部