I am wondering why gcc / g ++ is not able to put the generated object files in the specified directory.
For example:
mkdir builddir mkdir builddir/objdir cd srcdir gcc -c file1.c file2.c file3.c **--outdir=**../builddir/objdir
I know that this can be achieved with separate -o options given to the compiler, for example:
gcc -c file1.c -o ../builddir/objdir/file1.o gcc -c file2.c -o ../builddir/objdir/file2.o gcc -c file3.c -o ../builddir/objdir/file3.o
... and I know that I can write Makefiles through the VPATH and vpath directives to simplify this.
But this is a lot of work in a complex build environment.
I could also use
gcc -c file1.c file2.c file3.c
But when I use this approach, my srcdir is full of .o garbage afterwards.
So, I think the option with the -outdir semantics will be very useful.
What is your opinion?
EDIT : our Make files are written so that the .o files are actually placed in builddir / obj. But I'm just wondering if there could be a better approach.
EDIT . There are several approaches that put a burden on achieving the desired behavior in the build system (as well as Make, CMake, etc.). But I see them as workarounds for the weaknesses of gcc (and other compilers too).
gcc g ++
anon Nov 29 '09 at 0:37 2009-11-29 00:37
source share