在Windows上使用MinGW构建黄金链接器,FLEX/bison'YYSTYPE'未在此范围内声明

use*_*227 5 c++ mingw binutils gold-linker flex-lexer

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

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

我已经将./configure的完整输出包含在了一个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
Run Code Online (Sandbox Code Playgroud)

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

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

extern int
yylex(YYSTYPE*, void* closure);
Run Code Online (Sandbox Code Playgroud)

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

我是新手使用mingw和msys所以我可能错过了某些地方的某些步骤.任何帮助建立这个将非常感激.

Bri*_*汤莱恩 2

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

我下载了 binutils-2.25(最新版本)并尝试遵循您的操作。

我发现如果你只构建gold而不使用其余的binutils,它就不会构建。如果您执行最高级别的./configure操作make,则会获得金币。如果你然后cd gold执行./configureand make(尽管不必要),那么它也可以正常工作。

我确实发现,当它仅在黄金上失败时,它会比你的构建走得更远。

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

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

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