

#include <stdio.h>
int main(void)
{
printf("Hello world\n");
return 0;
}
gcc hello.c -o hello

gcc -E hello.c -o hello.i # Preprocessing stage
gcc -S hello.i -o hello.s # Compilation stage
gcc -c hello.s -o hello.o # Assembly stage
gcc hello.o -o hello # Linking stage

hello:hello.c
gcc hello.c -o hello



Using CMake to Generate Makefile
1. Command Line Operations
<span>cmake --version</span>
to check the CMake version. If it is not installed, execute the following command to install:sudo apt install cmake

<span>cmake_test</span>
folder contains a<span>hello.c</span>
file. Create a <span>CMakeLists.txt</span>
file in the same folder:
cmake_minimum_required (VERSION 3.10.2)
project (cmake_test)
add_executable(cmake_test hello.c)
<span>cmake_test</span>
directory, sequentially enter the following commands to generate the Makefile:mkdir build # Create build folder
cd build # Enter build folder
cmake ../ # Generate Makefile in cmake_test folder

<span>CMakeLists.txt</span>
file can refer to materials for further study.2. Using cmake-gui
<span>CMakeLists.txt</span>
and <span>hello.c</span>
files into a newly created folder called cmake-gui_test:
<span>cmake-gui</span>
to start the cmake-gui graphical tool. If it is not installed, you can enter the following command to install:sudo apt install cmake-qt-gui

<span>cmake-gui</span>
:





1
《6000 Words of Practical Content | Embedded Driver Learners Must Not Miss This Article!》
2
《Will Traditional Embedded C Programmers Disappear Under the New Programming Development Model?》
3
《No Way! Still Confused About the Differences Between Microcontroller Development and Linux Development?》

