小编Nic*_*der的帖子

生成带有完整路径的 gcc 依赖项

我有一个简单的项目,看起来像这样

\n\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 build\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.o\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 one\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.o\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 file2.o\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .depend\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n \xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.cpp\n \xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 one\n \xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.cpp\n \xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 file2.cpp\n
Run Code Online (Sandbox Code Playgroud)\n\n

Makefile 是这样的:

\n\n
# Get all of the source files\nSRC = $(shell find src/ -name "*.cpp")\n# Get all of the object files\nOBJ = $(subst src,build,$(SRC:.cpp=.o))\n\n$(OBJ):\n    @mkdir -p $(shell dirname $@)\n    g++ -g -c $(subst build,src,$(subst .o,.cpp,$@)) -o $@\n\nall: depend build\n\nbuild: $(OBJ)\n    gcc -o project $^\n\ndepend:\n    g++ -MM $(SRC) > .depend\n    sed -i …
Run Code Online (Sandbox Code Playgroud)

c++ makefile g++

5
推荐指数
1
解决办法
2894
查看次数

标签 统计

c++ ×1

g++ ×1

makefile ×1