简体   繁体   English

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

[英]Building gold linker with MinGW on Windows, FLEX/bison 'YYSTYPE' was not declared in this scope

I'm trying to build the gold linker included with GNU binutils using mingw. 我正在尝试使用mingw构建GNU binutils中包含的黄金链接器。 The steps I have taken- 我采取的步骤 -

  1. Install mingw with all packages using the installer. 使用安装程序安装所有包的mingw。
  2. Install the windows version of FLEX to the default location using the windows installer. 使用Windows安装程序将Windows版本的FLEX安装到默认位置。
  3. Run ./configure in the gold linker directory from the mingw shell which seems to work fine 从mingw shell中的gold链接器目录中运行./configure,这似乎工作正常
  4. Run make, this is where I'm getting some errors. 运行make,这是我遇到一些错误的地方。

I've included the complete output of ./configure and make in a pastebin here: http://pastebin.com/1XLkZVVm 我已经将./configure的完整输出包含在一个pastebin中: http//pastebin.com/1XLkZVVm

But the important part is this: 但重要的是这个:

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

I've looked in the script-ch file and it has this function: 我查看了script-ch文件,它有这个功能:

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

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

However YYSTYPE is not defined anywhere that I can find. 但是YYSTYPE没有在我能找到的任何地方定义。

I'm new to using mingw and msys so I may have missed some steps somewhere. 我是新手使用mingw和msys所以我可能错过了某些地方的某些步骤。 Any help getting this to build would be really appreciated. 任何帮助建立这个将非常感激。

As this question had lain unanswered for some months, I looked into the problem. 由于这个问题在几个月内没有得到答复,我调查了这个问题。

I downloaded binutils-2.25 (latest at this date) and tried to follow your actions. 我下载了binutils-2.25(此时为最新版本),并尝试按照您的操作。

I discovered that if you only build gold without the rest of binutils it does not build. 我发现,如果你只是在没有剩余binutils的情况下构建黄金,那么它就不会构建。 If you perform a ./configure and make at the top level it builds the gold fine. 如果你执行./configure并在顶层make它会构建金币。 If you then cd gold and do the ./configure and make (albeit unnecessarily) then it works fine also. 如果你然后cd gold并执行./configuremake (虽然不必要),那么它也可以正常工作。

I did find that when it failed on gold alone it got further than your build did. 我确实发现,当它单独使用黄金时,它比你的构建更进一步。

My attention was also drawn to your phrase FLEX to the default location . 我还注意到你的短语FLEX到默认位置 The instructions with FLEX make it clear that you should not rely on the default location (which may be /Program Files/ or similar) but must use path that does not contain any spaces. 使用FLEX的说明清楚地表明您不应该依赖于默认位置(可能是/Program Files/或类似),但必须使用不包含任何空格的路径。 If you had not noticed this, then that is your fault. 如果你没有注意到这一点,那那就是你的错。

As the latest builds, you can get gold working by ensuring you have installed flex (and bison) properly in non-space paths, then downloading 2.25 and building the whole of binutils rather than gold alone. 作为最新版本,您可以通过确保在非空间路径中正确安装flex(和bison),然后下载2.25并构建整个binutils而不是单独使用gold来获得黄金。

I hope this analysis is useful for someone who comes later and finds similar issues. 我希望这种分析对于后来出现类似问题的人有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM