Presentation is loading. Please wait.

Presentation is loading. Please wait.

MAKEFILES A description file that defines the relationships or dependencies between applications and functions; it simplifies the development process.

Similar presentations


Presentation on theme: "MAKEFILES A description file that defines the relationships or dependencies between applications and functions; it simplifies the development process."— Presentation transcript:

1

2 MAKEFILES A description file that defines the relationships or dependencies between applications and functions; it simplifies the development process by automatically performing tasks necessary to rebuild an application when you modify code.* *: http://www.ssec.wisc.edu/mcidas/do c/prog_man/2003/glossary.html#16 906 http://www.ssec.wisc.edu/mcidas/do c/prog_man/2003/glossary.html#16 906 BenefitsHow-toCalculator Example

3

4 CPP & Header Files You would have to compile each of these files separately to produce.o files and then link them all together. The following commands show how to do this. Notice the -c option you need to specify when you want to compile only, not to compile and link.

5 Time Consuming… Compile only: g++ -c main.cpp Compile only: g++ -c myfunction.cpp Link: g++ main.o myfunction.o -o main Note that if you wanted to compile a whole set of C++ programs at the same time, you could enter: g++ -c *.cpp Be careful with this though, for these reasons: - Using the wildcard "*" will refer to every.cpp file in the current directory. If you are going to use this, you should first put all the files for the program in a special directory for that program. - If you have only made a change to one file, there is no reason to compile every single file. In a program that consists of many files, this is extremely time-consuming.

6 Compiling & Linking Note that to link a whole set of object files you could have just entered: g++ *.o -o main Again, you should be careful that you have all your files in one directory. The following diagram illustrates how the previous example appears conceptually:

7

8 Without Makefile scenerio > g++ -c Calculatr.cpp > g++ -c DoMenu.cpp > g++ -c GetOperands.cpp > g++ -c AddNums.cpp > g++ -c ModNums.cpp > g++ -c Expon.cpp > g++ Calculatr.o DoMenu.o GetOperands.o AddNums.o ModNums.o Expon.o -o Calculatr Either recompile all (TIME CONSUMING) OR Just those are changed & their dependents (THIS ALSO TAKES YOUR TIME) Executable CompileLinkRe-link Re- compile

9

10

11

12 Inside of a Makefile File

13 How to Use It: simply enter make target at the system prompt

14


Download ppt "MAKEFILES A description file that defines the relationships or dependencies between applications and functions; it simplifies the development process."

Similar presentations


Ads by Google