compiling and linking
I'm trying to organize my source files into different subdirectories. My Makefile.am has this line:
myprg_SOURCES = a/a.c b/b.c c/c.c The problem is that the generated object files are placed in the current directory, but the linker tries to find them in their subdirectories, and therefore fails. a/a.o b/b.o c/c.o I've looked everywhere but can't find a solution. Any help would be appreciated! |
I fixed it!
Had to download the latest autoconf, automake, etc... The ones that came with RedHat 7.3 were from 1999!!!=?!"?"#¤$ |
I didn't know newer automake/autoconf versions work this way.
Anyways, in previous versions you should have an Makefile.am in each subdir: In dir a: myprg_SOURCES = a.c In dir b: myprg_SOURCES = b.c And then have a line: SUBDIRS = a b c in the Makefile.am in the root of your source tree. I have no idea which is the preferred method in the newer version of automake. Anyone? |
When I first tried to have a Makefile.am in each subdir it would try to build one executable in each directory.
Looking for a solution to that problem, I found an increasing opinion in favour of a single Makefile. I think it's somewhat "cleaner" with fewer files. It also seems to build faster, but that may be due to the newer and improved versions of the tools. |
Quote:
Alex |
Thanks! That straightened out a lot of confusions for me as to how Makefiles work.
|
All times are GMT -5. The time now is 10:11 AM. |