LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-23-2005, 11:24 PM   #1
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 435

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:

Code:
cc -o pascal y.tab.o 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.


Code:
pascal: y.tab.o lex.yy.o symbol.o main.o
	cc -o pascal y.tab.o 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

y.tab.o: y.tab.c globals.h
	 cc -c y.tab.c

lex.yy.o: lex.yy.c symbol.h y.tab.h
	 cc -c lex.yy.c

y.tab.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, 12:03 AM   #2
paulsm4
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, 12:52 AM   #3
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 435

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


Reply


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 with C gr33ndata Programming 4 11-18-2007 05:12 PM
Lex and Yacc on Federo 2.0 vivekian Fedora 6 05-20-2006 09:09 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


All times are GMT -5. The time now is 07:38 PM.

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