Makefile没有这样的文件或目录 [英] Makefile No such file or directory
本文介绍了Makefile没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试做一些简单的链接列表实践,以使自己熟悉C.我目前有以下makefile.
I'm trying to do some simple linked list practices to familiarize myself with C. I currently have the following makefile.
CC=gcc
CFLAGS=-Wall
app: linked_list.o app.c
$(CC) $(CFLAGS) linked_list.o app.c -o app
node.o: node.h
$(CC) $(CFLAGS) -c node.c
linked_list.o: linked_list.h
$(CC) $(CFLAGS) -c linked_list.h -o app
当我运行它时,我得到以下信息:gcc:错误:linked_list.o:没有这样的文件或目录
When I run it I get this: gcc: error: linked_list.o: No such file or directory
我尝试重新排序node.o和linked_list.o,但是没有任何效果.
I've tried reordering node.o and linked_list.o, but nothing worked.
推荐答案
您需要编译 .c
文件,而不是 .h
;并摆脱 -o应用
.
You need to compile the .c
file, not .h
; and get rid of -o app
.
linked_list.o: linked_list.c linked_list.h
$(CC) $(CFLAGS) -c linked_list.c
请确保在此处以及使用 node.o
:
Make sure to list both the .c
and .h
files as dependencies, both here and with node.o
:
node.o: node.c node.h
$(CC) $(CFLAGS) -c node.c
这篇关于Makefile没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文