- 前言
- 一、安装git-bash
- 二、安装MinGWMinGW-w64
- 2.1 MinGW是什么?
- 2.2 MinGW-gcc安装简图
- 2.2 MinGW-make安装简图
- 三、安装Make for Windows
- 3.1 下载安装包
- 3.2 设置环境变量
- 3.3 查看是否成功
- 四、安装gcc-arm-none-eabi-xx.xx
- 4.1 下载嵌入式编译器安装包
- 4.2 设置环境变量
- 4.3 查看是否成功
- 五、安装cmake
- 5.1 下载安装包
- 5.2 设置环境变量
- 5.3 查看是否成功
- 六、 vscode 设置终端默认位git_bash
- 七、 cmake+gcc+make工程实例
- 7.1 CMakeLists.txt
- 7.2 hello.c
- 7.3 执行
- 总结
前言
放弃keil,iar收费IDE,使用开源工具开发编译arm单片机程序。
一、安装git-bash
gitforwindos下载并安装gitbash
32位下载地址
MinGW - Minimalist GNU for Windows
64位下载地址
MinGW-w64 - for 32 and 64 bit Windows
MinGW 提供了一套简单方便的Windows下的基于GCC 程序开发环境。MinGW 收集了一系列免费的Windows 使用的头文件和库文件;同时整合了GNU ( http://www.gnu.org/ )的工具集,特别是GNU 程序开发工具,如经典gcc, g++, make等。MinGW是完全免费的自由软件,它在Windows平台上模拟了Linux下GCC的开发环境,为C++的跨平台开发提供了良好基础支持,为了在Windows下工作的程序员熟悉Linux下的C++工程组织提供了条件。
也就是说,为了方便将Linux下的程序少改动甚至不改动移植到windows下执行,跟ubuntu下的GCC是一样的地位
Make for Windows
因两种安装make的方法只是make的版本不同,而起的不同名字而已
四、安装gcc-arm-none-eabi-xx.xx 4.1 下载嵌入式编译器安装包The GNU Arm Embedded Toolchain
Windows x64 Installer
"terminal.integrated.profiles.windows": {
"bash_Shell": {
"path": "E:\runningware\Git\bin\bash.exe"
}
},
七、 cmake+gcc+make工程实例
7.1 CMakeLists.txt
# CMake 最低版本号要求
# cmake ../ -G "MinGW Makefiles"
cmake_minimum_required (VERSION 2.8)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
# 项目信息
set(PROJECT_NAME "hello")
project(${PROJECT_NAME})
# 指定生成目标,编译hello.cpp源程序,生成hello.exe的可执行程序
add_executable(hello hello.c)
7.2 hello.c
#include7.3 执行int main(){ printf("hello cmake!!!n"); return 0; }
$mkdir build && cd build $cmake ../ -G "MinGW Makefiles" $MinGW Makefiles
Administrator@YOS-O5TIEBE10FO MINGW64 ~/Desktop/temp/test/build $ cmake .. -G "MinGW Makefiles" CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argumentvalue or use a ... suffix to tell CMake that the project does not need compatibility with older versions. -- The C compiler identification is GNU 9.2.0 -- The CXX compiler identification is GNU 9.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: E:/runningware/minggw/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: E:/runningware/minggw/bin/g++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done
Administrator@YOS-O5TIEBE10FO MINGW64 ~/Desktop/temp/test/build $ /e/runningware/GnuWin32/bin/make.exe [ 50%] Building C object CMakeFiles/hello.dir/hello.c.obj [100%] Linking C executable hello.exe [100%] Built target hello
Administrator@YOS-O5TIEBE10FO MINGW64 ~/Desktop/temp/test/build $ ./hello.exe hello cmake!!!总结



