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

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

    I am trying to figure out the same thing. For me this worked

    CC = g++
    CFLAGS = -g -Wall -Iinclude
    CV4LIBS = `pkg-config --libs opencv4`
    CV4FLAGS = `pkg-config --cflags opencv4`
    
    default: track
    
    track:  main.o
        $(CC) -o track $(CV4LIBS) ./obj/main.o
    
    ALLFLAGS = $(CFLAGS) $(CV4FLAGS)
    main.o: ./src/main.cpp ./include/main.hpp
        $(CC) $(ALLFLAGS) -c ./src/main.cpp $(CV4LIBS) -o ./obj/main.o
    ``
    

提交回复
热议问题