makefile - 如何使用 makefile 在子目录中创建目标文件 - C 语言
问题描述
我想在 /objects 等子目录中创建所有 .o 文件,以保持 /src 井井有条。
我已经有了这个:
progr : main.o manipulate_strings.o environment_set.o variables.o segment_private.o rectangle_private.o circle_private.o tree.o dynamic_list.o visibility.o query.o
gcc -fstack-protector-all -std=c99 -g main.o manipulate_strings.o environment_set.o variables.o segments_private.o rectangle_private.o tree.o dynamic_list.o circle_private.o visibility.o query.o -o progr -lm
rm *.o
main.o : main.c manipulate_strings.o
gcc -fstack-protector-all -std=c99 -c -g main.c
manipulate_strings.o : manipulate_strings.c manipulate_strings.h
gcc -fstack-protector-all -std=c99 -c -g manipulate_strings.c
environment_set.o : environment_set.c environment_set.h
gcc -fstack-protector-all -std=c99 -c -g environment_set.c
variables.o : private/variables.c private/variables.h
gcc -fstack-protector-all -std=c99 -c -g private/variables.c -lm
segment_private.o : private/segments_private.c private/segments_private.h
gcc -fstack-protector-all -std=c99 -c -g private/segments_private.c -lm
rectangle_private.o : private/rectangle_private.c private/rectangle_private.h
gcc -fstack-protector-all -std=c99 -c -g private/rectangle_private.c
circle_private.o : private/circle_private.c private/circle_private.h
gcc -fstack-protector-all -std=c99 -c -g private/circle_private.c
tree.o : data_struct/tree.c data_struct/tree.h
gcc -fstack-protector-all -std=c99 -c -g data_struct/tree.c
dynamic_list.o : data_struct/dynamic_list.c data_struct/dynamic_list.h
gcc -fstack-protector-all -std=c99 -c -g data_struct/dynamic_list.c
visibility.o : visibility.c visibility.h
gcc -fstack-protector-all -std=c99 -c -g visibility.c
query.o : query.c query.h
gcc -fstack-protector-all -std=c99 -c -g query.c -lm
尽管它用 .o 文件填充了我的 src 目录,但它工作得很好。知道怎么做吗?
解决方案
推荐阅读
- python - 为什么每次重新启动代码后都会删除我的 Sqlite 数据库?(Python)
- angular - ag-grid 服务器端排序/分页社区版 Angular
- azure-data-explorer - 'distributed=true' 属性似乎不适用于从查询中提取
- c# - 无法在 ASP.NET Core 中初始化类?
- language-translation - 可以直接在 Office Translator、Edge Translator 或 Teams 聊天翻译中使用自定义翻译模型吗?
- three.js - 如何使用 Cannon.js 制作吸引点
- python-3.x - rpy2 在 Windows 系统上以什么顺序(以及如何)找到 R?
- excel - Excel VBA 中的自动筛选 - 日期相等 (=31.07.2021) 不同于日期更小 (< 31.07.2021)
- spring - 控制器方法外的Spring访问@RequestBody对象
- angular - 如何在Angular的常量文件中获取服务方法