gcc/g++ option to place all object files into separate directory

后端 未结 10 562
无人及你
无人及你 2020-11-30 19:44

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          


        
10条回答
  •  温柔的废话
    2020-11-30 20:14

    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 {} \;
    

提交回复
热议问题