Author Topic: Linking flex  (Read 8548 times)

twentytortures

  • Guest
Linking flex
« on: November 30, 2007, 08:46:43 pm »
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:
Code
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?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Linking flex
« Reply #1 on: December 01, 2007, 01:12:50 am »
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.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: Linking flex
« Reply #2 on: December 01, 2007, 02:00:55 pm »
Like TDragon mentioned, the file lex.yy.cc might not exist, you first need to execute the flex tool:
Code
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:
Code
flex -L -+ flexfile.l


BTW, the
Code
-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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Linking flex
« Reply #3 on: December 01, 2007, 05:44:16 pm »
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

  • Guest
Re: Linking flex
« Reply #4 on: December 01, 2007, 11:26:46 pm »
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.
« Last Edit: December 01, 2007, 11:42:42 pm by twentytortures »

twentytortures

  • Guest
Re: Linking flex
« Reply #5 on: December 01, 2007, 11:41:14 pm »
I've added all the MinGW stuff to my path and when I try to compile(from the command line) I get this:
Code
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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Linking flex
« Reply #6 on: December 02, 2007, 04:36:28 pm »
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."