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 yywrap()
. So, what's going on here?
I'm using Flex 2.5.35, gcc 4.7.2 and ld 2.22
add -lfl
at the end instead of beginning.
Use gcc lex.yy.c -ll
. Otherwise it will yield an undefined reference to yywrap
.
Alternatively, if you don't want to use the library, just #define yywrap()
1 in your .l file, or provide a yywrap()
method that returns 1.
It's documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With