4
votes

I'm taking a class on Flex/Bison at University this semester, and I'm having serious issues trying to get Flex working. (Possibly due to my own inaptitude, but I'm finding a solution very, very difficult to research)

I am trying to use the Command Prompt to navigate to a file containing a .l (Lex) file and then use Flex to generate a .yy file flex -ooutputfile.yy.c inputfile.l

After each and every attempt at a solution I continue to receive the message 'flex' is not recognized as an internal or external command, operable program or batch file.

I've spent several hours searching however I am at a loss. I've been unable to find any comprehensive instructions on how to install Flex or on it's requirements / dependencies... Any help would be much appreciated!

  • I added C:\Program Files\GnuWin32\bin to the PATH environment variables, System Variables. I am still getting the same error. (The location where flex.exe is located)
2
Open a command window and type path; this will show you the contents of the path variable. Is C:\Program Files\GnuWin32\bin in that list?eriktous
It's still not working though, I'm afraid.Eilidh
Okay, so the path is correct (and I assume you've checked that flex.exe is actually in that directory). Now type flex --version. If it still doesn't work, the file must be damaged and I would try reinstalling it.eriktous
I discovered the problem! The PATH was, effectively... C:\Ruby; C:\Flex This meant the path displayed when I looked for contents of the path variable, but did not actually work, changing it to (effectively) - C:\Ruby;C:\Flex - fixed the problem immediately!Eilidh

2 Answers

2
votes

The error you are getting means that flex.exe isn't in your PATH environment variable. You need to figure out where the installer installed flex and add that to your PATH or manually install it somewhere in your PATH

1
votes

you can use flex&bison under windows without any external dependencies at http://sourceforge.net/projects/winflexbison/. No need GnuWin32, perl or visual studio at all.