1.准備好樹莓派
2.使用
sudo apt-get install cmake
安裝cmake
3.建立項目文件夾
mkdir hello &&cd hello/
4.編寫main.c
#include<stdio.h> int main(void) { printf("hello world\n"); return 0; }
5.編寫CMakeLists.txt
cmake_minimum_required(VERSION 2.6) project(hello) add_executable(hello main.c)
6.使用 cmake . 在當前文件夾下生成makefile 使用make 編譯生成 可執行文件hello
7.運行hello
tip:若出現
No CMAKE_CXX_COMPILER could be found.
可以執行 sudo apt-get install -y build-essential 獲取必要環境