Saturday, 21 February 2009

undefined reference to _yywrap

cygwin,

$flex ch1-02.l
$gcc lex.yy.c -o ch1-02.exe
/cygdrive/d/Profiles/E6097C/LOCALS~1/Temp/ccFsaC7D.o:lex.yy.c:(.text+0x36c): und
efined reference to `_yywrap'
/cygdrive/d/Profiles/E6097C/LOCALS~1/Temp/ccFsaC7D.o:lex.yy.c:(.text+0xac1): und
efined reference to `_yywrap'
collect2: ld returned 1 exit status

solution: compile it with -lfl option.

gcc lex.yy.c -o ch1-02.exe -lfl

- Mihir Patel

5 comments:

  1. This does work.
    Thank you.

    ReplyDelete
  2. Thanks! That worked like a charm!

    I wish you also explained what these options mean..

    ReplyDelete
  3. OK.. i got it!

    So -lfl tells the linker to link with the library: libfl.a or libfl.so which are Flex libraries under /usr/lib

    :)

    ReplyDelete
  4. superb...thankyou

    ReplyDelete
  5. You could add this function instead and compile normally

    yywrap()
    {
    }

    ReplyDelete