News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Linking flex

Started by twentytortures, November 30, 2007, 08:46:43 PM

Previous topic - Next topic

twentytortures

I'm using flex(http://www.gnu.org/software/flex/flex.html) on windows and I'm having problems linking.
I don't know how much more I can explain, here is my output:
Compiling: F:\fun\flex\bin\lex.yy.cc
Execution of 'mingw32-g++.exe   -IF:\fun\flex\include  -c F:\fun\flex\bin\lex.yy.cc -o F:\fun\flex\bin\lex.yy.o' in 'F:\fun\flex\lib' failed.
Nothing to be done.

Under link libraries I have: F:\fun\flex\lib\libfl.a
Under other linker options I have: -lfl

I'm mostly a Java programmer so I'm not to familiar with the C++ compilers. I'm using MinGW to try to compile this. Am I doing something stupid?

TDragon

This could mean the file "lex.yy.cc" might not exist. Have you tried running that command (mingw32-g++.exe ... lex.yy.o) from a command prompt?

Note: I'm currently using Flex in a project, but only the C version; I've never tried the C++ interface.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

eranif

Like TDragon mentioned, the file lex.yy.cc might not exist, you first need to execute the flex tool:
flex -L  flexfile.l
where flexfile.l is your lexer's syntax file (usually suffixed with .l).
Once the compilation of the flex tool is done, you should have the default file name lex.yy.c Note that the default file is a 'C'. If you want to generate the C++ file, you should include FlexLexer.h, and invoke the flex like this:
flex -L -+ flexfile.l

BTW, the -L is for not including the #line directive in the generated code.

I suggest that you will add some pre build steps to generate lex.yy.c file prior compilation.

HTH,
Eran

thomas

Hmm... but it says "Execution of 'mingw32-g++.exe   [blah blah] failed.".

If the file lex.yy.cc was missing, it would say something like "mingw32-g++: Error: cannot open input file [blah blah]".

This looks more like a badly installed (or badly detected) MinGW to me.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

twentytortures

#4
Well I think my problem is that MinGW doesn't like Vista. I was able to get everything to compile fine from the command line at school on an XP machine. I can't even get it to compile on the command line on Vista. I would use a more windows friendly compiler instead but the problem I have is that I'm using a reference written for Linux so I'm not sure how the commands translate to windows compilers.

lex.yy.cc does exist. I generated it on the command line.

twentytortures

I've added all the MinGW stuff to my path and when I try to compile(from the command line) I get this:
gcc installation problem cannot exec 'cc1plus': Invalid Argument
I figure that once I get it working from the command line I could possibly get it working from codeblocks.

thomas

Vista is... well, Vista.

gcc 4.2 is reported to work well with Vista (other than 3.4), you may give that a try. Otherwise, there are a few threads on this forum (use forum search) that describe workarounds to make gcc 3.4 work under Vista too.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."