![where to put makefile for c program where to put makefile for c program](https://www.williamson-ga.us/wp-content/uploads/thon/makefile-template-c-programming-a-review-ppt-download-of-makefile-template-640x480.jpg)
Do you want to write this command again with hundreds of files? Obviously not! If you switch to another computer or terminal, you can not just run the previous command by pressing up and down button on the terminal. If you can do this, this tutorial is not for you. In above command, there are only two files, what if there are hundreds of files need to compile?ĭo you think is it comfortable to write this gcc compilation command by mentioning all these 100’s file names? There are certain problems with this commands. : Indicates that all the input files need to compile presents in the current directory. -o : This is a parameter to name your output the binary/executable file.gcc -o hellomake hellomake.c hellofunc.c -I. Run this following command in the compiler. If you are using gcc compiler, you have a straightforward run command to compile C program. So, you need to compile hellomake.c before hellofunc.c. Here, hellofunc.c depends on hellofunc.c. And function printHelloMake() is used in hellomake.c file. This is header file hellomake.h which contents the printHelloMake() function declaration. The function printHelloMake() is defined in hellofunc.c file. In other words, the makefile is used to organize the code compilation procedure.įor many, it sounds difficult to understand, let see the example where you need to follow the order of compilation. For example, one source file must be compiled before other one and likewise…īasically, the makefile is used to order the sequence of a compilation of files.
![where to put makefile for c program where to put makefile for c program](https://img-bbs.csdn.net/upload/201701/10/1484059113_379134.png)
All these different files have dependencies. The project usually have different files to compile and to make the executable binaries.
![where to put makefile for c program where to put makefile for c program](https://industriesbrown348.weebly.com/uploads/1/2/6/1/126197617/727207623.png)
Makefile, you may have seen in many projects.
#Where to put makefile for c program how to#
How to Create and Run Simple makefile?.