尝试制作一个编译cpp2html.c以生成cpp2html.o的makefile(我已经这样做了)。接下来,我必须运行 flex cppscanner.l 以从语言 cppscanner.l 生成文件 lex.yy.c。 (我已经这样做了)。然后我必须编译 lex.yy.c 来生成 lex.yy.o。最后链接 .o 文件。 (两者都完成)
cpp2html.o: cpp2html.c
[TAB] gcc -g -DDEBUG -c cpp2html.c //produces cpp2html.o
lex.yy.c: cppscanner.l
[TAB] flex cppscanner.l -o lex.yy.c //produces cppscanner language on lex.yy.c
lex.yy.o: lex.yy.c
[TAB] gcc -g -c lex.yy.c //produces lex.yy.o
cpp2html: cpp2html.o lex.yy.o
[TAB] gcc -g -DDEBUG cpp2html.o lex.yy.o -o cpp2html //links the .o files
我运行它时产生的错误是“调用时您的 makefile 未构建 'cpp2html':gcc -g -DDEBUG -c cpp2html.c
我做错了什么?提前致谢
最佳答案
错误消息表明存在规则
cpp2html: cpp2html.c
gcc -g -DDEBUG -c cpp2html.c
(目标缺少 .o
)某处。仔细检查该规则的拼写是否与您帖子中的一样,并且周围没有其他 makefile。
关于c++ - 使用flex的Makefile错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27433098/