我正在通过一个例如pgm来创建一个make文件。
http://mrbook.org/tutorials/make/
My folder eg_make_creation包含以下文件:
desktop:~/eg_make_creation$ ls
factorial.c functions.h hello hello.c main.c MakefileMakefile
all:gcc -c main.c hello.c factorial.c -o hello错误:
desktop:~/eg_make_creation$ make all
make: *** No rule to make target `gcc', needed by `all'. Stop.请帮助我理解编译这个程序。
发布于 2011-12-19 17:10:21
makefiles的语法非常严格:
target:dependencies
build_rules
# ^ this space here _needs_ to be a tab.你写的东西让all依赖于gcc,-c,...它们不是有效的目标。
您需要的内容如下:
all: hello
hello: factorial.c functions.h hello.c main.c
gcc -o hello factorial.c hello.c main.c (如果您希望在一个步骤中编译和链接,请不要使用-c开关)。
发布于 2013-08-14 23:04:50
马特搞定了。
在我的特殊情况下,我使用vi,并且默认情况下启用了expandtab!!
要查看此问题是否适用于您,请打开vi并执行以下操作:
:set list如果您没有在选项卡的位置看到^I,那么您很可能已经启用了et。
要禁用它,只需:
:set expandtab!也许这对其他人也有帮助。
发布于 2013-05-02 14:25:44
另一个原因是您在源文件列表中有错误的名称。(nameWrong.o而不是nameRight.o)这是我的问题。
https://stackoverflow.com/questions/8559033
复制相似问题