问题
I need to compile GDB for OS Linux targets but with Windows host OS. (The goal is to have possibility to run GDB client on Windows and connect it to the gdbserver running on Linux).
I'm using GDB sources v 9.2 and the following configure command:
../configure --build=x86_64-w64-mingw64 --target=x86_64-unknown-linux-gnu
It's running from the build directory inside gdb golder.
And I'm getting the following error:
mkdir -p -- nat/.deps
CXX gdb.o
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; did you mean 'yyrline'?
ada-exp.y:736:3: error: 'lexer_init' was not declared in this scope; did you mean 'pex_init'?
In file included from ada-exp.y:56:
ada-exp.y: At global scope:
ada-exp.y:55:29: warning: 'int ada_yylex()' declared 'static' but never defined [-Wunused-function]
../../gdb/yy-remap.h:38:39: note: in definition of macro 'GDB_YY_REMAP_2'
38 | #define GDB_YY_REMAP_2(PREFIX, YYSYM) PREFIX ## YYSYM
| ^~~~~~
../../gdb/yy-remap.h:40:29: note: in expansion of macro 'GDB_YY_REMAP_1'
40 | #define GDB_YY_REMAP(YYSYM) GDB_YY_REMAP_1 (GDB_YY_REMAP_PREFIX, YYSYM)
| ^~~~~~~~~~~~~~
../../gdb/yy-remap.h:40:45: note: in expansion of macro 'GDB_YY_REMAP_PREFIX'
40 | #define GDB_YY_REMAP(YYSYM) GDB_YY_REMAP_1 (GDB_YY_REMAP_PREFIX, YYSYM)
| ^~~~~~~~~~~~~~~~~~~
../../gdb/yy-remap.h:44:16: note: in expansion of macro 'GDB_YY_REMAP'
44 | #define yylex GDB_YY_REMAP (yylex)
| ^~~~~~~~~~~~
ada-exp.y:78:12: note: in expansion of macro 'yylex'
ada-exp.y:55:29: warning: 'int ada_yylex()' used but never defined
../../gdb/yy-remap.h:38:39: note: in definition of macro 'GDB_YY_REMAP_2'
38 | #define GDB_YY_REMAP_2(PREFIX, YYSYM) PREFIX ## YYSYM
| ^~~~~~
../../gdb/yy-remap.h:40:29: note: in expansion of macro 'GDB_YY_REMAP_1'
40 | #define GDB_YY_REMAP(YYSYM) GDB_YY_REMAP_1 (GDB_YY_REMAP_PREFIX, YYSYM)
| ^~~~~~~~~~~~~~
../../gdb/yy-remap.h:40:45: note: in expansion of macro 'GDB_YY_REMAP_PREFIX'
40 | #define GDB_YY_REMAP(YYSYM) GDB_YY_REMAP_1 (GDB_YY_REMAP_PREFIX, YYSYM)
| ^~~~~~~~~~~~~~~~~~~
../../gdb/yy-remap.h:44:16: note: in expansion of macro 'GDB_YY_REMAP'
44 | #define yylex GDB_YY_REMAP (yylex)
| ^~~~~~~~~~~~
ada-exp.y:78:12: note: in expansion of macro 'yylex'
ada-exp.y:1437:1: warning: 'type* type_char(parser_state*)' defined but not used [-Wunused-function]
ada-exp.y:1431:1: warning: 'type* type_long_double(parser_state*)' defined but not used [-Wunused-function]
ada-exp.y:1425:1: warning: 'type* type_long_long(parser_state*)' defined but not used [-Wunused-function]
ada-exp.y:1419:1: warning: 'type* type_long(parser_state*)' defined but not used [-Wunused-function]
make[2]: *** [Makefile:2370: ada-exp.o] Error 1
make[2]: Leaving directory '/z/tools/gdb-9.2/build/gdb'
make[1]: *** [Makefile:9572: all-gdb] Error 2
make[1]: Leaving directory '/z/tools/gdb-9.2/build'
make: *** [Makefile:860: all] Error 2
Here is what I have installed:
$ pacman -Qe
base 2020.05-2
bison 3.6.4-1
btyacc 20200330-1
flex 2.6.4-1
gdb 9.2-1
make 4.3-1
mingw-w64-x86_64-gcc 10.1.0-3
mingw-w64-x86_64-gcc-ada 10.1.0-3
mingw-w64-x86_64-python-ply 3.11-1
texinfo 6.7-2
Tried from both MSYS2 and MINGW64 shells.
回答1:
Could you try --build=x86_64-w64-mingw32
instead of --build=x86_64-w64-mingw64
and use MinGW64 shell not MSYS2 shell? (AFAIR there's some scripts in configure that matches *-*-mingw32* but not *-*-mingw* - I believe using --build=x86_64-w64-mingw32
helped me in past).
来源:https://stackoverflow.com/questions/62951784/gdb-compilation-fails-with-msys2-under-windows