Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-20-2004, 04:44 PM   #1
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15
LEX and YACC with C

Can I use LEX and YACC with a C compiler (GCC), or only C++ compilers (G++ and GCC -X C++) ??
Old 02-22-2004, 01:19 AM   #2
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 72

Rep: Reputation: 15
I've only compiled Lex and Yacc files only with C.

The Lex commands should be:
lex LexParse.l <-- makes lex.yy.c file
gcc lex.yy.c -ll <-- to compile the lex file made from previous step. -ll is used tell the compiler to use the lex libraries.

This Yacc command using the Lex file should be:
yacc Yacc.y <-- makes file
lex LexParse.l <-- makes lex.yy.c file
gcc lex.yy.c -ly -ll <-- to combine the lex and yacc file together.
Old 02-22-2004, 07:41 AM   #3
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ya, LEX and YACC are definitely C tools. There is support for C++ in flex but it is considered "experimental".
Old 11-18-2007, 01:34 AM   #4
LQ Newbie
Registered: Aug 2007
Location: Mysore(KAR), INDIA
Distribution: SLACKWARE12
Posts: 25

Rep: Reputation: 15


am using slakcware 12..

when i run "lex pg.l"
it creates lex.yy.c

but then when i run "gcc lex.yy.c -ll"
i get this error....
root@anil:~/dwnlds# gcc lex.yy.c -ll
/usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../i486-slackware-linux/bin/ld: cannot find -ll
collect2: ld returned 1 exit status

plz help me....
Old 11-18-2007, 05:12 PM   #5
LQ Newbie
Registered: Oct 2007
Location: Finland
Distribution: Slackware
Posts: 27

Rep: Reputation: 17
Slackware 12.0 contains flex.

Use -lfl option instead of -ll.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
does ubuntu have lex and yacc,how to use them?? akshay_jp Linux - Software 4 05-26-2010 06:36 PM
Lex and Yacc on Federo 2.0 vivekian Fedora 6 05-20-2006 09:09 AM
Error in Makefile for Lex and Yacc oulevon Programming 2 10-24-2005 12:52 AM
Lex and Yacc on Mandrake 9.2.2 Anuradha Linux - Software 0 07-02-2005 03:32 AM
Lex & YACC coolfrog Programming 3 09-25-2004 07:00 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration