我有 auto.lex
,我想生成此文件的 a.out
。
我试过了-
a.out: lex.yy.c
gcc -c lex.yy.c
lex.yy.c: auto.lex
flex -c auto.lex
但是没有用。
编辑:
改为-
a.out: lex.yy.c
gcc lex.yy.c
lex.yy.c: auto.lex
flex auto.lex
并修复了。
最佳答案
lex 文件的推荐后缀是.l
。 GNU make 有一个内置规则 .l.c
从 lex 源创建 C 代码。因此,如果您想从 auto.l
创建一个可执行文件 auto
,您根本不需要 makefile。只需输入 make auto
:
$ make auto lex -t auto.l > auto.c cc -c -o auto.o auto.c cc auto.o -lfl -o auto rm auto.o auto.c
关于c - 使用 makefile 从 lex 文件生成 a.out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13165681/