Linux make (Makefile) learning and sample Analysis __linux

Source: Internet
Author: User

Java EE Development of various types of resources download list, the history of the most complete IT resources, personal collection summary.

After a long time studying and studying the Linux GNU make project manager, now share the learning experience with you and hope this article will teach you something useful.

Make tool is a tool that all users who want to program on the Linux/unix system need and must master. If you write a program that does not use make tools, it means that the program you are writing is just a personal practice program, not a practical program, so we must learn, master and use it flexibly.

In a Linux/unix system, it is customary to use a makefile or Makfile file as the make command target file. The most important and basic function of make tools is to describe the interdependencies between source programs through makefile files and to automate the maintenance of compilation work. The makefile file needs to be written in a syntax that explains how to compile each source file and connect to build the executable file, and requires that you define dependencies between the source files.

The overall structure of multi-file compilation

As shown in the following illustration, this example includes float type addition, addition header function, int type addition, main main function, float type subtraction, subtraction header function, int type subtraction

Main function

[CPP]  View plain copy print? #include   "Add.h"    #include   "sub.h"    #include  <stdio.h>   int  main ()    {           int x, y;            float a, b;            x=5;           y=2;           a=5.5;            b=2.2;           printf ("%d + %d =  %d/n ",  x, y, add_int (x, y));            printf ("%3.1f + %3.1f = %3.1f/n",  a, b, add_float (a, b));           printf ("%d - %d = %d/n ",  x, y, sub_int (x, y));            printf ("%3.1f - %3.1f = %3.1f/n",  a, b, sub_float (a, b));           return 0;  }  

addition head function

[CPP] view plain copy print?   /* Add.h/* #ifndef _add_h_ #define _ADD_H_ extern int add_int (int x, int y);   extern float add_float (float x, float y); #endif

int type addition

[CPP] view plain copy print?   /* ADD_INT.C */int add_int (int x, int y) {return x+y; }

Float Type addition

[CPP]   View plain copy print/* add_float.c */<

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.