1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 在windows上 用cmake 交叉编译arm程序

在windows上 用cmake 交叉编译arm程序

时间:2021-04-05 15:06:51

相关推荐

在windows上 用cmake 交叉编译arm程序

在windows上,用cmake 交叉编译arm程序。生成器用nijia(或用MinGW,此时, cmake执行时,指定生成器为 -G “MinGW Makefiles”, 编译用make).

CMakeLists.txt

cmake_minimum_required(VERSION 3.6)project(testApp)file(WRITE main.cpp "int main(void) { return 0; }")set(testApp "testApp")list(APPEND testApp_sourcesmain.cpp)add_executable(${testApp}${testApp_sources})

toolchain.cmake

set(CMAKE_SYSTEM_NAME Generic)set(CMAKE_SYSTEM_PROCESSOR arm)set(CMAKE_C_COMPILER "arm-none-eabi-gcc.exe")set(CMAKE_CXX_COMPILER "arm-none-eabi-g++.exe")set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs" CACHE INTERNAL "")set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

在cmd 执行

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE:PATH="..\toolchain.cmake" ..-- The C compiler identification is GNU 8.3.0-- The CXX compiler identification is GNU 8.3.0-- Check for working C compiler: D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-gcc.exe-- Check for working C compiler: D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-gcc.exe -- works-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Detecting C compile features-- Detecting C compile features - done-- Check for working CXX compiler: D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-g++.exe-- Check for working CXX compiler: D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-g++.exe -- works-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Detecting CXX compile features-- Detecting CXX compile features - done-- Configuring done-- Generating done-- Build files have been written to: D:/work/clip/code/test/build

编译

>ninja[2/2] Linking CXX executable testApp

说下遇到的问题,出现以下错误:

D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-gccis not a full path to an existing compiler tool.Tell CMake where to find the compiler by setting either the environmentvariable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path tothe compiler, or to the compiler name if it is in the PATH.

原因是在window下,要把后缀也写上。下面是不行的。

set(CMAKE_C_COMPILER "D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-gcc")

改成

set(CMAKE_C_COMPILER "D:/sigmastar/flythings/sdk/platforms/ssd/toolchain/bin/arm-pc-linux-gnueabihf-gcc.exe")

您的支持是我持续创作的动力!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。