[clug] linking makefiles
David Tulloh
david.tulloh at infaze.com.au
Wed Jul 13 11:24:22 GMT 2005
You can either do it in a single makefile or in multiple files.
If you are only looking at linking in a few files then I think a single
file is far simpler.
For a single makefile you just need:
file: file.o ../A/i2c.o
../A/i2c.o: ../A/i2c.c ../A/i2c.h
If you had several you wanted to link in you can use a second makefile
to nicely group the dependancies.
A/Makefile
i2c.o: i2c.c i2c.h
B/Makefile
file: file.o ../A/i2c.o
../A/%.o:
make -C ../A $@
Both of these use implicit rules to do all the work.
deepshikha wrote:
> hello,
> i am having a problem compiling a C code. i have two directories and each
> one has a separate Makefile.
> a program(file.c) in directory 'B' needs to access a function which belongs
> to a file(i2c.c, i2c.h) in directory 'A'.
> how do i link the two files. will i have to make a new makefile?
> will appreciate any kind of help.
> thanks
More information about the linux
mailing list