FS#79780 - [flex] Undefined reference to yywrap
Attached to Project:
Arch Linux
Opened by Thomas Reim (rdratlos) - Monday, 25 September 2023, 14:24 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:15 GMT
Opened by Thomas Reim (rdratlos) - Monday, 25 September 2023, 14:24 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:15 GMT
|
Details
Description:
When building packages that use flex as development tool linking may abort with following error notification:'undefined reference to yywrap'. Analysis revealed that yywrap() is part of the provided flex include file FlexLexer.h and part of the provided shared libfl.so library. But flex yywrap() calls fail as shared library libfl.so cannot resolve required yylex() function. On the other hand when using static libraries for flex the error disappears and package build using flex succeeds. As shared libraries take precedence over static libraries during linking the trick here is to provide static library libl.a, which is linked to libfl.a. This is the configuration applied by main Linux distributions (Fedora, Ubuntu, etc.) in their development packages. Even if we can think about much better fix strategies there is a further dealbraker, which blocks other solutions. Package autoconf provides macros for checking the availability of flex libraries. These macros use the same approach as outlined below in section 'Steps to reproduce'- Proposal for a quick-fix would be to align ArchLinux package flex with other distributions and to provide also static libraries for using flex within other development projects. Attached is the required patch for PKGBUILD. Additional info: * all up to 2.6.4-5 Steps to reproduce: - Download file conftest.c - Execute gcc conftest.c /usr/bin/ld: /tmp/ccLxBjIx.o: in function `main': conftest.c:(.text+0xa): undefined reference to `yywrap' collect2: error: ld returned 1 exit status - Execute gcc conftest.c -lfl /usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib/libfl.so: undefined reference to `yylex' collect2: error: ld returned 1 exit status - Execute gcc conftest.c -ll /usr/bin/ld: cannot find -ll: No such file or directory collect2: error: ld returned 1 exit status - Patch PKGBUILD using PKGBUILD.diff, rebuild flex and install - Execute gcc conftest.c /usr/bin/ld: /tmp/ccLxBjIx.o: in function `main': conftest.c:(.text+0xa): undefined reference to `yywrap' collect2: error: ld returned 1 exit status - Execute gcc conftest.c -lfl /usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib/libfl.so: undefined reference to `yylex' collect2: error: ld returned 1 exit status - Execute gcc -o conftest conftest.c -ll Build succeeds with result code 0 and executing ./conftest finishes with result code 1 |
This task depends upon
Closed by Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:15 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/flex/issues/1
Saturday, 25 November 2023, 20:15 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/flex/issues/1
AC_PROG_LEX and AC_PROG_LEX(noyywrap) work while AC_PROG_LEX(yywrap) does not work. See attached archive for how I was testing.
The package I work on uses AM_PROG_LEX macro:
without static lib:
checking for lex library... none needed
checking for library containing yywrap... no
with static lib:
checking for lex library... none needed
checking for library containing yywrap... -ll
The ball is on your court :-)