Connecting Tech Pros Worldwide Forums | Help | Site Map

compilation error of Lex.yy.c

sam_cit@yahoo.co.in
Guest
 
Posts: n/a
#1: Mar 27 '06
Hi,
I just have the simple lex program
%%
. ECHO;
%%
int main()
{
yylex();
}

i did this, lex sample.l, which resulted in lex.yy.c then i tried to
complie the produced c file, on which i get the following error,

/tmp/ccYMo5KN.o: In function `yylex':
/tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
/tmp/ccYMo5KN.o: In function `input':
/tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
collect2: ld returned 1 exit status

Only way i have worked out is to have my own yywrap() function which
returns 1 always, but having said iam not able to understand the cause
of the problem, a simple lex program should work, like the following
%%
.. ECHO;
%%

but why isn't?


santosh
Guest
 
Posts: n/a
#2: Mar 27 '06

re: compilation error of Lex.yy.c


sam_cit@yahoo.co.in wrote:[color=blue]
> Hi,
> I just have the simple lex program
> %%
> . ECHO;
> %%
> int main()
> {
> yylex();
> }
>
> i did this, lex sample.l, which resulted in lex.yy.c then i tried to
> complie the produced c file, on which i get the following error,
>
> /tmp/ccYMo5KN.o: In function `yylex':
> /tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
> /tmp/ccYMo5KN.o: In function `input':
> /tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
> collect2: ld returned 1 exit status
>
> Only way i have worked out is to have my own yywrap() function which
> returns 1 always, but having said iam not able to understand the cause
> of the problem, a simple lex program should work, like the following
> %%
> . ECHO;
> %%
>
> but why isn't?[/color]

This is not a good place to ask this question, as it deals only with
standard C. Ask either in comp.compilers or a group specific to your
tools, which you've not specified.

Rod Pemberton
Guest
 
Posts: n/a
#3: Mar 27 '06

re: compilation error of Lex.yy.c



<sam_cit@yahoo.co.in> wrote in message
news:1143443085.739966.187330@i39g2000cwa.googlegr oups.com...[color=blue]
> Hi,
> I just have the simple lex program
> %%
> . ECHO;
> %%
> int main()
> {
> yylex();
> }
>
> i did this, lex sample.l, which resulted in lex.yy.c then i tried to
> complie the produced c file, on which i get the following error,
>
> /tmp/ccYMo5KN.o: In function `yylex':
> /tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
> /tmp/ccYMo5KN.o: In function `input':
> /tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
> collect2: ld returned 1 exit status
>
> Only way i have worked out is to have my own yywrap() function which
> returns 1 always, but having said iam not able to understand the cause
> of the problem, a simple lex program should work, like the following
> %%
> . ECHO;
> %%
>
> but why isn't?
>[/color]

You're missing an '%option noyywrap'. You usually need a yywrap() function.
So, I'd recommend adding one for now:

int yywrap()
{
return(1);
}

http://www.gnu.org/software/flex/man...mono/flex.html



Closed Thread