gdb编译问题yyin和lexer_init

问题描述

我正在尝试在Ubuntu 18.04中编译gdb 9.2,将显示以下错误

make[2]: Entering directory '/home/ata/gdb-9.2/build/gdb'
  CXX    ada-exp.o
ada-exp.y: In function ‘int ada_parse(parser_state*)’:
ada-exp.y:736:15: error: ‘yyin’ was not declared in this scope
ada-exp.y:736:15: note: suggested alternative: ‘yylen’
ada-exp.y:736:3: error: ‘lexer_init’ was not declared in this scope
ada-exp.y:736:3: note: suggested alternative: ‘pex_init’
In file included from ada-exp.y:56:0:

gdb 10.1在此之前已成功编译。

我在线搜索,但无法提供原因或解决方案。

可能是什么问题?

编辑1:我有gcc version 7.5.0

解决方法

我也遇到过这个问题,我是这样解决的:
ada-exp.y 包含文件 ada-lex.c,其中包含函数 lexer_init 的定义。
但是如果您最初没有安装 flex,那么它可能会生成一个空的 ada-lex.c(来自 ada-lex.l)。即使你做了 make clean,它也不会清理生成的 ada-lex.c,也就是说,它在下一个编译命令时也会保持为空。
因此,要修复此错误,您可以删除所有此类中间 .c 文件(在您的情况下,使用新的 .tar.gz 构建)并再次执行 make。