Re: Makefile question
- From: Logan Shaw <lshaw-usenet@xxxxxxxxxxxxx>
- Date: Wed, 09 Jan 2008 23:28:08 -0600
xz wrote:
I am learning how to deal with Makefile and got so confused.
Could anyone be so kind and give a little sample Makefile for the
following particular example?
Let's say I have the following files describing 4 classes (A, B, C1,
C2) and a test program (test.cpp) which runs a test for classes C1 and
C2.
A.h
A.cpp
B.h
B.cpp
C1.h
C1.cpp
C2.h
C2.cpp
test.cpp
The inhirentance relation among the 4 classes are as follows:
class C1: public B
class C2: public B
class B: public A
i.e. C1 and C1 are both dependent on B while B is dependent on A.
test.cpp depends on C1 and C2 and contains the main() function.
I am on a linux machine(Ubuntu 7.10) and use g++ 4.1 as the compiler.
Then how should I write the Makefile? Thanks a lot in advance!
Class inheritance doesn't matter at all. You just need to define
the interfaces in the .h files and put the code in the .cpp files.
Then, you need to compile the .cpp files. Since each .cpp file is
built independently of the other and depends only on the header
files, it does not matter what order they are compiled in.
Ideally you should put the dependencies (including transitive
dependencies) for every file in its line in the makefile. But
there are tools to generate those dependencies for you and
write them into the makefile.
- Logan
.
- References:
- Makefile question
- From: xz
- Makefile question
- Prev by Date: Re: Confusion between Stack and Data segment
- Next by Date: Re: Confusion between Stack and Data segment
- Previous by thread: Makefile question
- Next by thread: Re: Makefile question
- Index(es):
Relevant Pages
|