【发布时间】:2013-09-16 22:02:02
【问题描述】:
我对 C 和编程很陌生,所以我希望你们有一点耐心。 但是,我尝试尽可能准确地描述我的问题。 我在我的 Windows 7 计算机上使用 mingw32,我刚刚了解了“make”。 我已经编写了一些源代码文件和一个 Makefile。我想要的是 Makefile 编译我的源代码 int 目标代码,然后将其链接到一个可执行文件 (我想这对专业人士来说并不疯狂)。
这是我的代码:
first.c:
#include<stdio.h>
#include"second.h"
int main()
{
float x = 12.0;
printf("Result is: %.2f\n",go_to_the_other(x));
return 0;
}
秒.h
float go_to_the_other(float f);
秒.c
float go_to_the_other(float f)
{
float calc = f + 10;
return calc;
}
Makefile 是(是的,我只使用了标签):
second.o: second.c second.h
gcc -c second.c
first.o: first.c
gcc -c first.c
first: first.o second.o
gcc first.o second.o -o first
这只是一个简单的例子,但它几乎描述了我的问题。 我将所有文件都放在同一个目录中,我使用命令行:
mingw32-make first
但我没有编译我的文件,而是只收到消息:
cc first.c -o first
process_begin: CreateProcess(NULL, cc first.c -o first, ...) failed
make (e=2): The system cannot find the file specified.
<builtin>: recipe for target 'first' failed
mingw32-make: ***[first] Error 2
我想这可能真的很愚蠢,但我就是想不通 我做错了什么。我真的很感激这方面的任何帮助。 非常感谢您。
【问题讨论】:
-
这很奇怪。它正在执行构建
first的命令,这些命令甚至不在您的makefile 中。它似乎正在为c文件的 make 规则选择默认值。您显示的makefile和源代码是否都在同一个文件夹中,并且没有其他 makefile 存在?文件名为makefile还是Makefile?另外,我假设您输入的是mingw32-make而不是mingw32 -make。