2015-06-16 45 views
0

这是我的makefile:错误: 'CFLAGS' 没有指定类型

CFLAGS=-Wall -g -O2 

clean: 
    rm -f ex1 

当我运行一个脚本,例如,这个人(ex3.c):

#include <stdio.h> 

int main() 
{ 
    int age = 10; 
    int height = 72; 

    printf("I am %d years old.\n", age); 
    printf("I am %d inches tall.\n", height); 

    return 0; 
} 

我得到出现以下错误:

$ g++ Makefile.c -o makefile 
Makefile.c:1:1: error: 'CFLAGS' does not name a type 
CFLAGS=-Wall -g 
^g++  ex3.c -o ex3 
$ 
+1

'g ++ Makefile.c -o makefile'真的吗? – billz

+0

'gmake ex3'?... – BLUEPIXY

+1

你很困惑。 'makefile'是构建脚本。 'ex3.c'文件是需要编译的程序。 *脚本*包含将您的源文件转换为可执行文件的说明。 –

回答

2

请不要编译makefile

改为使用make实用程序。

同义词包括nmakegmake

该生成文件应传递给make程序或生成实用程序。

+0

非常感谢你,我现在想通了。 – Farid