Reputation: 273
I write simple flex program and run it in linux with following code
flex filename.l
cc lex.yy.c -lfl
./a.out
but now I want to run it in windows I do orders in following link now I am trying to compile flex file with following commend but it says that cc is not recognized then I try to compile it with following commend
gcc lex.yy.c -lfl
and it says that cannot find -lfl
, then I try this
gcc lex.yy.c
but i got a lot of error for example undefined reference to yywrap
. what should I do to recognize flex libraries ?
Upvotes: 2
Views: 9168
Reputation: 21619
The issue is that it cant find the library. On linux it would be under /usr/bin or usr/local/bin which are both on the system path. On windows there is no such standard place for libraries.
When you use the -lfl option it will search on the system path for a file called libfl.o (shared library) or libfl.a (static library) and link your binary with this file.
So what you need to do is provide the location of the library using the -L option for gcc.
Your new compile command would therefore be.
gcc lex.yy.c -L<path to library> -lfl
Upvotes: 5