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

后端 未结 10 575
无人及你
无人及你 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:00

    Meanwhile I found a "half-way" solution by using the -combine option.

    Example:

    mkdir builddir
    mkdir builddir/objdir
    cd srcdir
    
    gcc -combine -c file1.c file2.c file3.c -o ../builddir/objdir/all-in-one.o
    

    this "combines" all source files into one single object file.

    However, this is still "half-way" because it needs to recompile everything when only one source file changes.

提交回复
热议问题