Setting Up and Using Flex (Lex for Windows) with Visual C++ 6.0

 

Contributed by Stephen Seymour

I have written this HTML page for those who are interested in using the "lex" and "yacc" unix commands on Microsoft Windows machines. It is assumed that the reader has some knowledge (but not much) of the Visual C++ 6.0 integrated development environment.

The first thing you need to do is to download the necessary software. Although there are many clones available all over the web, the following link will download the files for you to build programs using Visual Studio 6.0: Click Here for Download the Flex and Bison Tools.

After you have downloaded the zip file from clicking the above link, extract all the files to a directory of your choice and then run the "setup.exe" file. This will install "Flex.exe" and "Bison.exe" on a Windows machine. The installation process will find the appropriate directories on your computer that house Visual Studio 6.0 and will install the necessary files into those directories.

Running the Lex Program:

For the sake of helpfulness, I will give an example assuming the "Flex.exe" program was installed in the "C:\Program Files\Microsoft Visual Studio\Common\Bin" directory. However, if you have a path to this directory predefined in your environmental variables, you won't need to type in the entire path to the "Flex.exe" program. Regardless of where the "Flex.exe" program is, if it is not defined as an environment variable then all you have to do is fill in the entire path to it in the appropriate places in the following example:

The above steps should have created a "lex.yy.c" file or a "lex.yy.cpp" file, which we will now use to compile into an executable using Visual Studio 6.0

I hope this helps!