Makefile Practical Guide: Start from Scratch for Effortless Code Compilation

Introduction: Are you also a “Command Repeater”? Every time you compile code, you have to type a long string of commands: gcc -o app main.c tool.c -I./include -L./lib -lm…… Change a line of code, and you have to type it all over again; if you mistype a character, you have to start from scratch — … Read more

Essential C Language Development | A Comprehensive Guide to Makefile: From Basics to Advanced Applications

Essential C Language Development | A Comprehensive Guide to Makefile: From Basics to Advanced Applications

Follow and star our public account for exciting content Source: Internet Makefile is a compilation control file widely used for automating project builds. It defines a series of rules to guide the build process. With Makefile, developers can easily manage compilation, linking, cleaning, and other tasks for large projects. This article will start with the … Read more

Getting Started with Makefile: From Rules to Automated Builds

Getting Started with Makefile: From Rules to Automated Builds

By mastering the variables, rules, implicit rules, and automatic variables of Makefile, you can transform scattered compilation commands into a stable, efficient, and reusable build pipeline. Make Build Process 1. Basic Syntax of Makefile (Minimal Working Example) A simple Makefile: CC = gcc CFLAGS = -O2 -Wall SRC = main.c util.c OBJ = $(SRC:.c=.o) all: … Read more

CMake Advanced Techniques

CMake Advanced Techniques

With further progress, there are advanced techniques, this article mainly introduces some of my habits on Windows. Windows GUI applications Windows console applications do not display the console black box Generating .sln files on Windows Custom CMake variables Super useful custom operations Built-in commands (copy, delete, etc.) Execute commands Generate files make install Windows GUI … Read more

C Language Project Management Tool: Writing Makefile

C Language Project Management Tool: Writing Makefile

C Language Project Management Tool: Writing Makefile What is Makefile? A Makefile is a text file that contains instructions for automating the build process. In C language projects, Makefiles are particularly useful as they help manage code compilation, linking, and other related tasks. By using a Makefile, you can run a single command to automatically … Read more

Practical Debugging Techniques for Makefile

Practical Debugging Techniques for Makefile

In the previous sections, we discussed the basic rules, functions, and patterns of makefiles. When writing makefiles in practice, we often encounter various issues. How can we quickly and effectively solve these problems? Here, I will introduce several common techniques to help us better handle and resolve the issues we encounter. MakefileDebugging Technique1 During the … Read more

Understanding Phony Targets in Makefile

Understanding Phony Targets in Makefile

<span>Makefile</span> phony targets are a very important concept. They are used to define targets that do not directly correspond to files, but are used to perform specific operations (such as cleaning files, running tests, etc.). 1. Introduction: What is a Phony Target? 1.1 Definition of Phony Targets A phony target is a target that does … Read more

A Comprehensive Guide to Makefile: From Basics to Advanced Applications

A Comprehensive Guide to Makefile: From Basics to Advanced Applications

Makefile is a compilation control file widely used for automating project builds. It defines a series of rules to guide the build process. With Makefile, developers can easily manage compilation, linking, cleaning, and other tasks for large projects. This article will start with the basic usage of Makefile and gradually delve into more advanced applications, … Read more

Embedded Functions in Makefile

Embedded Functions in Makefile

subst String Replacement Function $(subst <from>, <to>, <text>) replaces the <from> string in <text> with <to> and returns the replaced string. SRC:=/mnt/hgfs/share/123 DES:=$(subst /mnt,/root,$(SRC)) #ATTENTION: is, /root not, /root all: @echo $(SRC) @echo $(DES) /mnt/hgfs/share/123 /root/hgfs/share/123 patsubst Pattern String Replacement Function $(patsubst <pattern>, <replacement>, <text>) checks if the words in <text> (separated by spaces, tabs, … Read more

Introduction to Makefile

Introduction to Makefile

Makefile is created for this problem; it defines a set of rules that determine which files need to be compiled first, which files later, and which files need to be recompiled. — Liang Xu, Linux Source: zhuanlan.zhihu.com | Author: Liang Xu, Linux 1. What is Makefile In an enterprise-level project, there are usually many source … Read more