【问题标题】:Building gold linker with MinGW on Windows, FLEX/bison 'YYSTYPE' was not declared in this scope在 Windows 上使用 MinGW 构建黄金链接器,FLEX/bison 'YYSTYPE' 未在此范围内声明
【发布时间】:2013-06-27 14:54:00
【问题描述】:

我正在尝试使用 mingw 构建包含在 GNU binutils 中的黄金链接器。我采取的步骤-

  1. 使用安装程序安装 mingw 和所有软件包。
  2. 使用 Windows 安装程序将 Windows 版本的 FLEX 安装到默认位置。
  3. 在 mingw shell 的黄金链接器目录中运行 ./configure,似乎工作正常
  4. 运行 make,这是我遇到一些错误的地方。

我在此处将 ./configure 和 make 的完整输出包含在一个 pastebin 中: http://pastebin.com/1XLkZVVm

但重要的是:

make[2]: Entering directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
g++ -DHAVE_CONFIG_H -I.  -I. -I./../include -I./../elfcpp -DLOCALEDIR="\"/usr/lo
cal/share/locale\"" -DBINDIR="\"/usr/local/bin\"" -DTOOLBINDIR="\"/usr/local//bi
n\"" -DTOOLLIBDIR="\"/usr/local//lib\""   -W -Wall    -Wno-format -Werror -D_LAR
GEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=expression.o  -MT expression.
o -MD -MP -MF .deps/expression.Tpo -c -o expression.o expression.cc
In file included from expression.cc:33:0:
script-c.h:221:7: エラー: 'yylex' initialized and declared 'extern' [-Werror]
script-c.h:221:7: エラー: 'YYSTYPE' was not declared in this scope
script-c.h:221:15: エラー: expected primary-expression before ',' token
script-c.h:221:17: エラー: expected primary-expression before 'void'
script-c.h:221:30: エラー: expression list treated as compound expression in ini
tializer [-fpermissive]
cc1plus.exe: all warnings being treated as errors
make[2]: *** [expression.o] Error 1
make[2]: Leaving directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
make: *** [all] Error 2

我查看了 script-c.h 文件,它有这个功能:

/* Called by the bison parser skeleton to return the next token.  */

extern int
yylex(YYSTYPE*, void* closure);

但是 YYSTYPE 没有在我能找到的任何地方定义。

我是使用 mingw 和 msys 的新手,所以我可能在某处遗漏了一些步骤。任何帮助构建它都将非常感激。

【问题讨论】:

    标签: c++ mingw flex-lexer binutils gold-linker


    【解决方案1】:

    由于这个问题几个月来一直没有答案,我调查了这个问题。

    我下载了 binutils-2.25(目前是最新版本)并尝试按照您的操作进行操作。

    我发现如果你只构建黄金而不使用其他 binutils,它就不会构建。如果您在顶层执行./configuremake,它会生成金币。如果您然后 cd gold 并执行 ./configuremake(尽管没有必要),那么它也可以正常工作。

    我确实发现,当它仅在黄金上失败时,它比你的构建更进一步。

    您的短语FLEX 到默认位置也引起了我的注意。 FLEX 的说明清楚地表明您不应依赖默认位置(可能是/Program Files/ 或类似位置),而必须使用不包含任何空格的路径。如果你没有注意到这一点,那是你的错。

    作为最新的构建,您可以通过确保已在非空间路径中正确安装 flex(和 bison),然后下载 2.25 并构建整个 binutils 而不是单独构建黄金来获得黄金。

    我希望这个分析对后来发现类似问题的人有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多