Question:

Help makefile syntax?

by  |  earlier

0 LIKES UnLike

I have three files that need to be compiled using a make file.

They are

employee.h

employee.cpp

main.cpp

What would the syntax be for these. And can you explain how you come up with this.

Thanks

 Tags:

   Report

2 ANSWERS


  1. hi

    You can get the sample code from the book at

    http://www.wrox.com/WileyCDA/Section/id-...

    Please let us know if that helped or if you have resolved the problem some other way.

    thanks


  2. The simplest way to make the makefile for this is like this: http://rafb.net/p/xKdkpM74.html

    The "all" is the name of the make rule. Since it's the first one in the makefile, it is the one that will be used if no rule is specified.

    After "all:" is a list of dependencies -- every file or other rule that the "all" rule relies on. If any file in a rule's dependency tree has been altered, that rule will rerun (this way, make only recompiles if necessary).

    The line below it is the command for that make rule. In this case, it just compiles everything from the source.

    If you want to get more complicated, you could write individual rules for each source file (or group of source files), and then an "all" rule that has the other rules as its dependencies. You can also use variables within the makefile to make it easier to write out the commands.
You're reading: Help makefile syntax?

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.