未创建可执行文件(hello),已创建两个程序的对象文件

时间:2014-04-09 07:09:32

标签: c

#!bin/bash
CC=gcc /*gcc compiler*/
CFLAGS=-I. /*current working directory*/
hello: p1.o p2.o p.h /*hello is the executable i want to create*/
    $(cc) -o hello p1.o p2.o p.h -I.

显示的错误是

o hello p1.o p2.o p.h -I.
make: o: Command not found
make: [hello] Error 127 (ignored)

通过make来创建代码的目标文件但是不创建可执行的hello

1 个答案:

答案 0 :(得分:4)

make的变量区分大小写。你需要写

$(CC) -o hello p1.o p2.o p.h -I.

由于$(cc)未设置,make将尝试执行-o hello ...。前导短划线会抑制make语法中的错误,因此生成的命令是您看到的o hello ...