瑞芯微Rockchip开发者社区
直播中

chunhuahua

8年用户 1342经验值
擅长:接口/总线/驱动
私信 关注
[问答]

ROC-RK3566-PC板交叉编译报错咋办

2.jpg

问题描述及复现步骤:

命令行直接编译是可以通过的,但是通过CmakeList 编译是 通不过

cmake_minimum_required(VERSION 3.5.1)

project(learn_test)

#告诉CMAKE是进行交叉编译

set(CMAKE_CROSSCOMPILING TRUE)

#设置此时进行编译的系统

set(CMAKE_SYSTEM_NAME "Linux")

#指定交叉编译器的路径

set(COMPILER_PATH "/opt/sysroot/firefly-arm64-sysroot-18.04/usr")
set(CMAKE_CXX_COMPILER "${COMPILER_PATH}/bin/aarch64-linux-gnu-g++")

add_executable(learn_test src/test.cpp)

gobot@ubuntu:~/learn_test/build$ make
Scanning dependencies of target learn_test
[ 50%] Building CXX object CMakeFiles/learn_test.dir/src/test.cpp.o
/opt/sysroot/firefly-arm64-sysroot-18.04/usr/bin/aarch64-linux-gnu-g++: 1: /opt/sysroot/firefly-arm64-sysroot-18.04/usr/bin/aarch64-linux-gnu-g++: ELF E@ c@8: not found
/opt/sysroot/firefly-arm64-sysroot-18.04/usr/bin/aarch64-linux-gnu-g++: 1: /opt/sysroot/firefly-arm64-sysroot-18.04/usr/bin/aarch64-linux-gnu-g++: Syntax error: word unexpected (expecting ")")
CMakeFiles/learn_test.dir/build.make:62: recipe for target 'CMakeFiles/learn_test.dir/src/test.cpp.o' failed
make[2]: *** [CMakeFiles/learn_test.dir/src/test.cpp.o] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/learn_test.dir/all' failed
make[1]: *** [CMakeFiles/learn_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

回帖(1)

李莉

2022-12-29 16:47:05
/opt/sysroot/firefly-arm64-sysroot-18.04/usr/bin/aarch64-linux-gnu-g++
这个是sysroot里面aarch64自己的g++,不是交叉编译器,你file一下会发现是arm64架构的,在x86上无法运行
交叉编译器自行安装apt install crossbuild-essential-arm64
然后会在电脑的/usr/bin/aarch64-linux-gnu*,你再file一下,这个才是x86架构的
举报

更多回帖

发帖
×
20
完善资料,
赚取积分