views:

260

answers:

2

I'm using flex (lexical analyzer, not Adobe Flex) on a project. However, I want to be able to compile on Windows platforms as well, but the Windows version's newest version is only 2.5.4a, so it won't compile my file for version 2.5.35. And no, I can't downgrade to the highest supported Windows version.

Anyone know about plans to upgrade the windows version, or have a suggestion to compile on windows anyway?

+3  A: 

You can ask on the mailing list, or get involved in the Flex project yourself. I think the code-base for GNU Flex has remained static for a while, but I don't know who maintains the Windows port. In the interim...

I would recommend including the produced source in your project.

  1. Generate the lexer on a Linux system to produce your lex.c/lex.h files (or whatever)
  2. Include those files in your Win32 C source before you build

If you don't have direct access to a Linux system, a virtual machine might be a good idea. The Flex source should be complaint to some C standard that builds on Windows, but most of the POSIX differences can be altered to use Win32 API fairly easily.

Maybe distribute as:

/src/source_files.c
/src/lex.l
/src/win32_lex/lex.c

This way systems with a modern flex can generate the source from the lex file, and Windows systems compiling the source can use the complementary pre-processed C files.

Short of using some user-space POSIX (Cygwin or whatever).

A little bit of tweaking required, but isn't that portability for you!

Aiden Bell
+1, personally I just use Cygwin when the .lex/.y files change.
Simeon Pilgrim
Could you explain how to use Cygwin to compile using the Linux version of Flex? I did try to use it for this project, but didn't get very far.
Jorn
How to compile the Flex source itself, or generate the C files from Flex? There *should* be a cygwin version of Flex already
Aiden Bell
+1  A: 

Windows builds of flex 2.5.35 do exist, but unfortunately they are not self contained. You can download the MINGW build here, and the Cygwin build here; see also another stackoverflow question. Each build requires that its respective (MINGW or Cygwin) kernel be installed.

JPaget