bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: automatic linking links too many files


From: James Coleman
Subject: Re: automatic linking links too many files
Date: Fri, 22 May 2009 16:04:00 +0100
User-agent: Thunderbird 2.0.0.21 (X11/20090320)


Hello,

The intent of the default rule is to make it easy to handle object files or libs I think. So it makes sense that for you the file is assumed to be an object file and is passed to the link line.

For anything other than very simple cases you will make your own rules.

1.
Do you actually want to make a dependancy on a file/files like textfile?
I think in that case it would be easiest to define your own rule.

You may have a point that there is something unexpected in make.
I don't see what rule would match textfile and treat it as an object file. But I'm not sure.


2.
If you just want to use default rule and have one c file yhen you want maybe a very simple makefile containing:
all: executable

$ make -f makefile.all
g++     executable.cpp   -o executable


3.
If you have more than one c file you add a dependancy on the other c files object files:
executable: othercfile.o

$ make -f makefile.other
g++    -c -o othercfile.o othercfile.cpp
g++     executable.cpp othercfile.o   -o executable


4.
I notice that adding a static library doesn't get picked up by a default rule. I'm not going to dig further into this. My syntax for libs might be wrong, makefile.lib:
executable: othercfile.o staticlibrary.a

staticlibrary.a: yetanothercfile.o


$ make -f makefile.lib
g++    -c -o othercfile.o othercfile.cpp
g++    -c -o yetanothercfile.o yetanothercfile.cpp
g++     executable.cpp othercfile.o staticlibrary.a   -o executable
g++: staticlibrary.a: No such file or directory
make: *** [executable] Error 1


Just thinking a bit out loud, hope this is of some use to you also.

James.


Federico Poloni wrote:
`Makefile' contains:
executable: textfile

the output of `make' is
g++     executable.cpp textfile   -o executable





reply via email to

[Prev in Thread] Current Thread [Next in Thread]