Linux programming 1: Write makefile

Source: Internet
Author: User

Makefile example:

Test: Add. O sub. ogcc-O test add. O sub. oadd. o: Add. C test. hgcc-C add. csub. o: sub. C test. hgcc-c sub. c clean: Rm-RF testrm-RF *. O

Format:

Name of the file to be generated (including the suffix): List of dependent files (including the suffix) GCC-O/-C [If an executable file is generated, set the file name here; generate *. o file not needed] list of dependent file names (including suffix names)

Note:

1. If the *. o file is compiled, use gcc-o. If the *. c file is compiled, use gcc-C.

2. *. H files do not need to be compiled in makefile, because. c files call. H files for compilation.

3. Save the content of makefile as a text file named "makefile", and then enter the command "make" in the terminal to execute makefile for compilation.

4. "clean:" Is a tag. If you enter "make clean" in the interrupt, the command after "clean:" is executed (in this example, the generated file is deleted ).

5. rm is the command to delete files, and-RF is the command to force delete files in a series of subfolders.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.