win10-64bit搭建cmake+gcc-linaro-arm-linux-gnueabihf的編譯環境

【1】軟件包準備

下載cygwin,請自行按需下載,給出參考地址:https://cygwin.com/install.html

下載cmake,請自行按需下載,給出參考地址:https://cmake.org/download/

 下載gcc-linaro-arm-linux-gnueabihf,請自行按需下載,給出參考地址:https://www.cnblogs.com/huty/p/8518302.html

下載Make For Windows ,請自行按需下載,給出參考地址:http://www.equation.com/servlet/equation.cmd?fa=make

【2】軟件安裝

安裝cmake和cygwin軟件,並將其加入環境path,例如:

D:\workForSoftware\CMake\bin
D:\workForSoftware\cygwin64\bin
D:\workForSoftware\cygwin64\sbin

將make.exe放置cygwin工作路徑或將其所在目錄加入環境path。

cmake -version和make -v測試

安裝 gcc-linaro-arm-linux-gnueabihf,本文安裝路徑爲

D:\workForSoftware\Linaro\gcc-linaro-arm-linux-gnueabihf-4.9

【3】樣例構建與編譯

建立源代碼main.cpp

#include <iostream>

int main(int, char**) {
    std::cout << "Hello, world!\n";
}

建立CMakeLists.txt文件

cmake_minimum_required(VERSION 3.0.0)

#arm
set(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_SYSTEM_NAME linux)
SET(CMAKE_SYSTEM_PROCESSOR "arm")

set(g_dir "D:/workForSoftware/Linaro/gcc-linaro-arm-linux-gnueabihf-4.9/bin")
set(CMAKE_C_COMPILER "${g_dir}/arm-linux-gnueabihf-gcc.exe") 
set(CMAKE_CXX_COMPILER "${g_dir}/arm-linux-gnueabihf-g++.exe")

project(test_for_cmake)

add_executable(test_for_cmake main.cpp)

【4】編譯make,類似如下圖

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章