Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. The steps I have taken-

  1. Install mingw with all packages using the installer.
  2. Install the windows version of FLEX to the default location using the windows installer.
  3. Run ./configure in the gold linker directory from the mingw shell which seems to work fine
  4. Run make, this is where I'm getting some errors.

I've included the complete output of ./configure and make in a pastebin here: 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-c.h file and it has this function:

/* 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.

I'm new to using mingw and msys so I may have missed some steps somewhere. Any help getting this to build would be really appreciated.

like image 896
user2380227 Avatar asked Nov 02 '22 19:11

user2380227


1 Answers

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.

I discovered that if you only build gold without the rest of binutils it does not build. If you perform a ./configure and make at the top level it builds the gold fine. If you then cd gold and do the ./configure and make (albeit unnecessarily) then it works fine also.

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. 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. 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.

I hope this analysis is useful for someone who comes later and finds similar issues.

like image 142
Brian Tompsett - 汤莱恩 Avatar answered Nov 12 '22 20:11

Brian Tompsett - 汤莱恩