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 

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,类似如下图

win10-64bit搭建cmake+gcc-linaro-arm-linux-gnueabihf的编译环境_第1张图片

你可能感兴趣的:(物联网,编译环境/工具,产品化)