日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2024/3/24 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在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")

您的支持是我持續創作的動力!

總結

以上是生活随笔為你收集整理的在windows上,用cmake 交叉编译arm程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。