1 .Docker运行文件目录
arduino
Docker目录下安装环境:
sudo apt-get update //更新安装包信息
sudo apt-get install build-essential //安装编译器调试器(gcc、g++、gdb)
sudo apt-get install crossbuild-essential-arm64 //安装交叉编译工具链(aarch64-linux-gnu-gcc)
sudo apt-get install make cmake // 安装 make和cmake
2.CMakeLists.txt
文件名不要错!!!!!!!
scss
cmake_minimum_required(VERSION 3.5.1)
project(ublox)
set(PROJECT_VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
# 设置链接器标志 写法一
SET(GCC_COVERAGE_LINK_FLAGS "-static")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
# 设置链接器标志 写法二
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
add_executable(
ublox
main.cpp
)
# 将 pthread 库链接到 ublox 目标
target_link_libraries (ublox pthread)
3.CMake 本地编译结果
go
build以此执行以下命令
make
cmake ..
file ublox
4.Toolchain-aarch64.cmake
bash
# 设置系统名称为 Linux
set(CMAKE_SYSTEM_NAME Linux)
# 设置系统处理器为 aarch64
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# 设置目标 ABI(Application Binary Interface)为 aarch64-linux-gnu
set(TARGET_ABI "aarch64-linux-gnu")
# 设置 C 编译器为 aarch64-linux-gnu-gcc
set(CMAKE_C_COMPILER ${TARGET_ABI}-gcc)
# 设置 C++ 编译器为 aarch64-linux-gnu-g++
set(CMAKE_CXX_COMPILER ${TARGET_ABI}-g++)
5.Cmake交叉编译
ini
cmake -DCMAKE\_TOOLCHAIN\_FILE=../Toolchain-aarch64.cmake ..
make
file ublox