Re: subdirs and object files - anyone please help

hyper^T <jcook2 bigpond net au> writes:
> Can someone tell me how to use the file properly
> This is the problem 
> I have a directory called src with the main file called main.c.  every file
> includes main.h 
> I also have a subdirectory called menu (src/menu)
> in there is menu.c, menu.h, filemenu.c, filemenu.h ..........
> main.c includes menu.h ..... so in the end when it comes time to compile
> link main.o with src/menu.o it doesn't work because gcc is looking for
> menu.o not src/menu.o
> So the problem is as soon as main.c depend's on [any f*cking
> subdirectroy]/filename.o shit hits the fan

main.c depending on subdir/filename.o sounds pretty wrong (should be
compiled_app depends on main.o and subdir/filename.o, I would assume)
- but I know what you mean...

> could someone tell me how for over 30 years software engineers have been
> able to, by keeping in the file heirachy, get around my problem

automake does not let you have stuff in _SOURCES not in the same
directory as the The complications here are srcdir !=
builddir and situations like that maybe.

The way around it is what the automake docs call a "convenience
library." You build a static library in the subdirectory with a in that subdirectory, then add the static library to the
link line in the parent directory.

I can't think of a package with a simple example offhand, but someone
else probably can. And it's in the automake docs.


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