Flukiluke Flukiluke - 1 year ago 85
C Question

flex: undefined reference to `yywrap' only when compiling/linking separately

I've been learning to use Flex (the lexical analyser) and I've been compiling with the following command:

gcc -lfl -o test lex.yy.c

and all is well. However, I want to link it with other files, so I compile and link it separately with

gcc -c lex.yy.c

followed by

gcc -lfl -o test lex.yy.o

but gcc tells me that there is an undefined reference to
. So, what's going on here?

I'm using Flex 2.5.35, gcc 4.7.2 and ld 2.22

Raj Raj
Answer Source

add -lfl at the end instead of beginning.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download