Welcome to the most active Linux Forum on the web.
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 10-24-2005, 12:24 AM   #1
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 437

Rep: Reputation: 30
Error in Makefile for Lex and Yacc

As I mentioned in a previous thread, I'm writing a compiler for a subset of Pascal (Appendix A of the Dragon Book). I've been given the lex and yacc files to get me started as well as some other sample code including a makefile. This makefile is about 6 years old. When I run make, I get the following error:

cc -o pascal lex.yy.o symbol.o main.o -ll -ly 
/usr/bin/ld: cannot find -ly
collect2: ld returned 1 exit status
make: *** [pascal] Error 1

Does anyone know what the -ly option is doing?

I'm going to be changing the makefile so that it uses gcc instead of cc. Is there an analogous option for gcc ?

I'll post the makefile for reference.

Thanks for any help.

pascal: lex.yy.o symbol.o main.o
	cc -o pascal lex.yy.o symbol.o main.o -ll -ly 

symbol.o: symbol.c globals.h
	cc -c symbol.c

main.o: main.c symbol.h
	cc -c main.c globals.h
	 cc -c

lex.yy.o: lex.yy.c symbol.h
	 cc -c lex.yy.c pascal.y symbol.h globals.h lex.yy.c
	yacc -d pascal.y

lex.yy.c: pascal.l symbol.h
	lex pascal.l
Old 10-24-2005, 01:03 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"-ll" links in the "lex" library, and "-ly" links in yacc.

If you're using "flex", then you don't need "-ll" ... but you DO need to have your "main()" (or some other function) call your "yylex()".

I assume you're probably using the GNU equivalents of "lex" and "yacc". If so, you'll probably have to make a few (minor!) changes to your makefile (and possibly your code).

If you're using GNU flex and bison, I encourage you to spend a few minutes with the GNU documentation, successfully build a little "hello world" ... and only then revisit your Pascal project.

Your .. PSM
Old 10-24-2005, 01:52 AM   #3
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 437

Original Poster
Rep: Reputation: 30
Thanks for your help.


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 07:36 PM
LEX and YACC with C gr33ndata Programming 4 11-18-2007 06:12 PM
Lex and Yacc on Federo 2.0 vivekian Fedora 6 05-20-2006 10:09 AM
Lex and Yacc on Mandrake 9.2.2 Anuradha Linux - Software 0 07-02-2005 04:32 AM
Lex & YACC coolfrog Programming 3 09-25-2004 08:00 AM

All times are GMT -5. The time now is 01:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration