c++ - 使用flex的Makefile错误

标签 c++ c makefile flex-lexer

尝试制作一个编译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/

相关文章:

c++ - 错误: lvalue required while operator overloading++/-- etc

android - 如何在编译android内核期间修复函数的隐式声明

c - 字符串一旦定义就不能初始化为其他字符?

c - 每 x 秒运行一次函数

c++ - 生成文件/nmake : strip out folder bits from the file list

iphone - 构建在 XCode 中运行的 C 库最终会出现不受支持的架构

c++ - freopen和cout创建内部错误

c++ - 串联仅在感觉合适时才起作用?

c++ - 函数模板

linux - NVIDIA Jetson TX2 中无法识别的命令行选项 '-m64'