c - 使用make时没有这样的文件或目录错误
问题描述
我对 Linux 还比较陌生,但我的操作系统课程中有一个涉及多个文件的作业。我的教授给了我们他的makefile,但它对我不起作用。Make 只返回错误。我知道我拥有与教授相同的所有文件,虽然我的还没有完成,但我没有理由看到代码无法编译。
这是生成文件:
sync: sync.c prodcons.c prodcons.h producer.c producer.h consumer.c consumer.h Makefile
${CC} -g -Wall -pthread -o sync ssync.c prodcons.c producer.c consumer.c ln -sf sync assn4
这是我收到的错误消息:
J_studentid@cs3060:~/assn4$ make
cc -g -Wall -pthread -o sync sync.c prodcons.c producer.c consumer.c ln -sf sync assn4
cc: error: ln: No such file or directory
cc: error: sync: No such file or directory
cc: error: assn4: No such file or directory
cc: error: unrecognized command line option ‘-sf’; did you mean ‘-Hf’?
Makefile:2: recipe for target 'sync' failed
make: *** [sync] Error 1
J_studentid@cs3060:~/assn4$
我看到教授在课堂上编译和运行代码,所以我知道它有可能工作,但它给我带来了问题。我很乐意提供更多信息或代码,但我认为文件的内容与编译错误无关。谢谢!
解决方案
我很确定这是您的 makefile 的预期源代码,它既有效又有效:
all:
${CC} -g -Wall -pthread -o sync ssync.c prodcons.c producer.c consumer.c
ln -sf sync assn4
您的 makefile 的问题是:
- 没有默认目标,即缺失
all:
ln -sf sync assn4
被用作编译器参数
此外,请确保命令行(例如,${CC} ...
)始终以 TAB 字符开头。我无法判断您的代码块中是否有一些,因为它们在这里自动更改为空格,但想指出。
推荐阅读
- rust - 我可以阻止创建或使用类型的引用吗?
- css - 如何使用css制作滑块水平移动的动画并做出反应?
- flutter - TextStyle 不能识别accentColor 并返回错误的颜色
- java - PDFBox 2.0.9 - pdf 到带有 alpha 的图像
- python - 删除属于另一个单词的单词
- dns - 为什么我们可以创建两个具有相同 DNS 名称的区域?
- next.js - NextJs - 使用 fetch() 通过 POST 方法进行 api 调用 - 总是 ERR_ABORTED 400
- java - Java swing JTextArea & JScrollPane,垂直滚动有效但水平滚动无效,一行向下
- javascript - 如何在 react-native 中对 SectionList 进行分页
- python - 将每日数据重采样为工作日数据