[Reading Notes] "C Programmer from Campus to Workplace" Chapter 6 Configuration File, Makefile (Part 2)

 Contents:

1. Configuration file (usually ends with ini)

2.makefile statement (Linux)

 


 

 1. Configuration file

Reference link:

Let you know software development in advance (12): configuration file reading and file operation 

CSDN blog https://blog.csdn.net/zhouzhaoxiong1227/article/details/23552667

 

2. Makefile

        The makefile is used to compile the entire project under Linux, and it is crucial for the compilation of the C/C++ language under Linux.

       This article takes the actual C source program as an example to introduce how to use the makefile to compile the C language project under Linux, which provides a reference for the development of related development work.

 【Key words】

        makefile C language Linux compilation development

1. What is a makefile?

        what is makefile? If you're writing a program that only runs under Windows, chances are you don't know it exists. And if you're going to compile and run a program under Linux, you'll almost inevitably have to deal with makefiles.

        A makefile is a file that defines a series of rules to specify which files in a project need to be compiled first, which files need to be compiled later, which files need to be recompiled, and even more complex functional operations. Simply put, makefile is a compilation scheduler under Linux.

 

2. Syntax rules of makefile

        Since it is a compile scheduler, it will have its own set of rules. The rules of the makefile are as follows:

target ... : prerequisites ...

command

......

......

        illustrate:

       (1) target is a target file, that is, in this step, the file name (which can include a suffix) we want to output.

       (2) prerequisites are the files needed to generate that target, which is equivalent to the source code files we need to get the exe file under the Windows project.

       (3) command is the command that make needs to execute, that is, how to use prerequisites to generate target. Note that the command line must start with the TAB key.

 

3-5. Take an actual C program project under Linux (convert lowercase letters in a string to uppercase letters) as an example to introduce the writing method and usage of makefile.

Reference: Let you know software development in advance (17): Writing and application of makefile files

           CSDN blog https://blog.csdn.net/zhouzhaoxiong1227/article/details/24812071

 

6. Summary

        This article introduces the syntax rules of makefile files, and uses an actual C program project to illustrate its usage.

        In the process of writing and using makefiles, we should pay attention to the following issues:

        (1) Keep in mind the syntax of makefile and clarify the dependencies of different program files.

        (2) The command line must start with the TAB key, and do not mistakenly write a space.

        (3) At the end of the makefile, clean up the useless intermediate files (such as the .o file in this example).

        (4) For errors or warnings in the make command, be sure to modify them as much as possible.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325116515&siteId=291194637