[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yywrap() undefined reference and 'flex --noyywrap' option
From: |
Daniel J Sebald |
Subject: |
yywrap() undefined reference and 'flex --noyywrap' option |
Date: |
Sat, 19 May 2012 14:20:47 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
Below is an observation that perhaps someone with lots of Autotools
experience can utilize to slightly clean up acinclude.m4. Basically
../octave/configure LEX='flex --noyywrap'
seems to achieve the result of requiring 'flex' (as opposed to lex...is
that what is wanted as HACKING says?) and determines no '-lfl' library
is needed.
I tried making it work from inside configure.ac, but couldn't and
decided to move on to programming.
Dan
configure:59019: gcc -o conftest -g -O2 -pthread conftest.c -lm >&5
/tmp/cc4I4k2Q.o: In function `input':
/usr/local/src/octave/oct-build/lex.yy.c:1168: undefined reference to
`yywrap'
/tmp/cc4I4k2Q.o: In function `yylex':
/usr/local/src/octave/oct-build/lex.yy.c:867: undefined reference to
`yywrap'
/tmp/cc4I4k2Q.o: In function `main':
/usr/local/src/octave/oct-build/conftest.l:17: undefined reference to
`yywrap'
collect2: ld returned 1 exit status
configure:59019: $? = 1
configure: failed program was:
| /* confdefs.h */
I read through the GNU Autotools documentation yesterday so I now
understand the flex/yywrap error message. The Autotools AC_PROG_LEX
macro tries to figure out whether a library is needed. The macro tries
compiling with '', then '-lfl', then '-ll' and stops at whatever
compiles correctly. In this case, automake believes '-lfl' is required.
However, Octave supplies yywrap() so that the flex library isn't really
needed. Hence, in acinclude.m4 is the following override:
AC_PROG_LEX
case "$LEX" in
flex*)
LFLAGS="-I"
AC_MSG_RESULT([defining LFLAGS to be $LFLAGS])
LEXLIB=
;;
*)
Autotools suggests the same in its documentation. I.e.,
http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Particular-Programs.html)
AC_SUBST([LEXLIB], [''])
It seemed odd to me that Autotools would have such lengthy discussion
about yywrap() and not have a clean way of dealing with it but instead
suggest an after-the-fact fix. Flex has an option of 'noyywrap' either
at the command line or within the lexical scripts. The option replaces
yywrap with 1 (i.e., true). For fun, I tried configuring with
../octave/configure LEX='flex --noyywrap'
which yields the desired result:
configure:58916: checking for flex
configure:58943: result: flex --noyywrap
configure:58980: flex --noyywrap conftest.l
configure:58984: $? = 0
configure:58986: checking lex output file root
configure:59000: result: lex.yy
configure:59005: checking lex library
configure:59019: gcc -o conftest -g -O2 -pthread conftest.c -lm >&5
configure:59019: $? = 0
configure:59029: result:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- yywrap() undefined reference and 'flex --noyywrap' option,
Daniel J Sebald <=