交叉编译报错
命令行直接编译是可以通过的,但是通过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: *** Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/learn_test.dir/all' failed
make: *** Error 2
Makefile:83: recipe for target 'all' failed
make: *** Error 2
可否来个大神解答一下? /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架构的
页:
[1]