我怎样才能为 minGW 创建一个简单的 makefile? gfortran
我对 gfortran+minGW 绝对是新手。 我需要创建 makefile。 当我运行时
$ gfortran -c q.f
一切都好! 但是我怎样才能像这样运行makefile呢?
CC = gfortran
q.o : q.f
$(CC) -c q2.o q2.f
我收到错误“CC:未找到命令”。
(操作系统 – Win 7 (64)) 坦克!!!
I am absolutely new in gfortran+minGW.
I need to create makefile.
When I run
$ gfortran -c q.f
All is ok!
But how can I run makefile like this?
CC = gfortran
q.o : q.f
$(CC) -c q2.o q2.f
I receive error “CC: command not found”.
(OS – Win 7 (64))
Tanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正尝试将 makefile 作为常规脚本运行。 请尝试使用
或
如果您将该文件命名为“makefile”或“Makefile”以外的名称,
。您可以只执行makefile,但如果是这样,您需要一个“shebang”行,类似于
文件顶部的内容,但坦率地说,几乎没有人使用该选项。只需使用 make(1) 命令即可。
更新
这是因为它们的顺序错误。 Makefiles 处理(默认情况下)文件中的第一个目标。当您运行 make 时,它会看到要生成的规则,即来自
qf
的qo
,它会对其进行编译,并说:“好吧,我完成了。”如果您将
q.exe
目标放在第一位,它会显示“嗯,我想构建 q.exe,为此我需要一个 qo 我有 qo 吗?没有?好吧,我”我有一个规则 - 我可以从 qf 构建 qo 好的,现在我可以构建 q.exe 吗?哦,是的,我可以构建 q.exe 吗? , 我受够了。”如果你要使用command,
那么你会明确地告诉make make q.exe,这会导致同样的事情发生,但更好的是你应该重新排序你的makefile并习惯它们的工作方式。
It kind of looks like you're trying to run the makefile as a regular script. Try
or
if you named the file something other than "makefile" or "Makefile".
You can potentially just execute the makefile, but if so you need a "shebang" line, something like
at the top of the file, but frankly hardly anyone uses that option. Just use the make(1) command.
Update
It's because they're in the wrong order. Makefiles process (by default) the first target in the file. When you run make it sees the rule to make,
q.o
fromq.f
, it compiles it, and says, "Okay, I'm done."If you put the
q.exe
target first, it says "Hmmm, I want to build q.exe and to do that I need a q.o. Do I have a q.o? No? Okay, hen I'll build a q.o. I have a rule for that -- I can build a q.o from q.f. okay, that's done. Now can I build q.exe? Oh, yes, I can. I'll build q.exe. Anything? Nope, I'm done."If you were to use the commend
then you'd explicitly tell make to make q.exe, which would cause the same thing to happen, but better you should reorder your makefile and get used to the way they work.