I am wondering why gcc/g++ doesn\'t have an option to place the generated object files into a specified directory.
For example:
mkdir builddir mkdir
A trivial but effective workaround is to add the following right after the gcc call in your Makefile:
mv *.o ../builddir/objdir
or even a soft-clean (possibly recursive) after the compilation is done, like
rm -f *.o
or
find . -name \*.o -exec rm {} \;