[Interest] FLex / Bison and QT4 4.8.1 Win32 interaction

K. Frank kfrank29.c at gmail.com
Tue Jul 12 05:33:27 CEST 2016

Hi Fabio (and Scott)!

On Mon, Jul 11, 2016 at 8:22 PM, Scott Aron Bloom <scotty at t42.com> wrote:
> My company uses Cygwin’s Flex and Bison.
> We use CMake, and had to create our own module for Flex and Bison, not too
> hard, but if you are using qmake, I cant help.
> He have no problem with the build step from .y to .h and .cpp

Scott's comment makes me realize that I should correct my earlier
misguided comment.

Lex / yacc, flex / bison are not libraries that get linked into your
application -- rather they are free-standing applications themselves
that produce compilable source files.  So all of my nonsense about
needing to build flex / bison with the same (or compatible) compiler
as you used to build qt and your application is just wrong.

You just need to find a version of the flex and bison executable that
will run on your build machine.  As Scott mentioned, you could run
cygwin (a unix emulator for windows) on a windows machine, and
use its version of flex / bison.  Or you could find a native (i.e.,
non--cygwin) windows version of flex / bison.  I imagine that there
is one out there.  (Michael mentioned that gnuwin32, as shipped
with qt5, contains a version of flex / bison.)

Lastly, your build machine  doesn't have to be windows.  You could,
for example, build your windows qt executable by cross-compiling
on a linux machine, and run linux's version of flex / bison on that
linux build machine.

Or, if your parser is stable -- i.e., doesn't need to be modified as
you maintain and upgrade your application -- you could (hackishly)
just copy over the parser code (the output of flex / bison) to a
windows build machine, and remove the flex / bison processing
step from your build process.  (This, of course, would be very
EVIL (TM), and violate all manner of good-housekeeping source
control practices.)

Sorry for the previous noise.  There's no compiler compatibility issue,
so I can't see any reason you would need (or want) to build flex /
bison from source.  Simply find pre-built flex / bison executables
that run on your build machine.

As a side comment, Bill suggested that you might pass on flex / bison,
and hand-code your own parser.  There is some aspirational virtue to
Bill's view, and it might even make sense if you were starting a new
project.  But given that you already have a working, tested, field-tested
flex / bison grammar for your application's parser, rewriting that parser
by hand would be a bad idea, falling clearly into the "if it ain't broke,
don't fix it" category of time-sucking mistakes.

> Scott

Again, sorry for my earlier nonsense.

Happy Parser-Generating!

K. Frank

> [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf
> Of Fabio Giovagnini
> ...
> Thanks guys. But under linux my tool has been working 10 years long flex/
> bison based. So i must to make them working under windows. Thanks alot. By
> the way from a certain standing point i agree with the "from the scretch"
> solution. But i had to think about it 10 years ago... now it is a bit late
> :-) ciao
> Fabio
> On 07/07/2016 08:01 PM, Fabio Giovagnini wrote:
> Thanks Frank. So you suggest to build from the sources. I' try. Thanks again
> ...
> Il 07/lug/2016 17:40, "K. Frank"
> ha scritto:
>     Ciao Fabio!
>     On Thu, Jul 7, 2016 at 7:19 AM, Fabio Giovagnini <fab at gio.com
>     <mailto:fab at gio.com>> wrote:
>     >  Ciao to all.
>     >  I have an application linux native based on:
>     >  1) qt4 (4.8.1)
>     >  3) lex/bison
>     >
>     >  Under Ubuntu 14.04 and prevoius everithing ok.
>     >
>     >  Under Windows, I cannot find lex/bison support.
>     >  I have to say that I installed only QT SDK (w/ MinGW support)
>     >  Any suggestion will be really appreciated.
>     Windows does not come with built-in flex / bison support, nor
>     does mingw, nor (to the best of my knowledge) does Qt. (This
>     is true of a lot of unix-world libraries that are nearly universal
>     on various flavors of unix.)
>     I would expect (but don't know for a fact) that you could find a
>     third-party port of flex / bison to windows that you could then
>     use for your Qt / flex / bison project. In general, you would be
>     best off if you found a port built with the same compiler as your
>     Qt project (apparently mingw). One way to insure this would be
>     to build it yourself. If you're careful and know what your doing
>     you can sometimes get away with using c libraries compiled with
>     a different compiler (For example, the ms system calls were not
>     compile with mingw and you can call into those.), but it's likely to
>     be more bother trying to mix compilers than compiling something
>     like flex / bison yourself.
>     >  Thanks
>     >  Fabio
>     Happy Parsing!
>     K. Frank
> ...

More information about the Interest mailing list