Linker Error Yywrap
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this lex yy c undefined reference to yywrap site About Us Learn more about Stack Overflow the company Business Learn more
%option Noyywrap
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x libmatheval yywrap Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined Reference
Undefined Reference To Yywrap Centos
To yywrap up vote 60 down vote favorite 12 I have a simple "language" that I'm using Flex(Lexical Analyzer), it's like this: /* Just like UNIX wc */ %{ int chars = 0; int words = 0; int lines = 0; %} %% [a-zA-Z]+ { words++; chars += strlen(yytext); } \n { chars++; lines++; } . { chars++; } %% int main() { yylex(); splint undefined reference to yywrap printf("%8d%8d%8d\n", lines, words, chars); } The I run a flex count.l, all goes ok without errors or warnings, then when I try to do a cc lex.yy.c I got this errors: ubuntu@eeepc:~/Desktop$ cc lex.yy.c /tmp/ccwwkhvq.o: In function yylex': lex.yy.c:(.text+0x402): undefined reference to yywrap' /tmp/ccwwkhvq.o: In function input': lex.yy.c:(.text+0xe25): undefined reference to yywrap' collect2: ld returned 1 exit status What is wrong? flex-lexer share|improve this question edited May 6 '13 at 11:13 lesmana 13k64470 asked Nov 28 '09 at 0:30 Nathan Campos 10.3k38149260 add a comment| 3 Answers 3 active oldest votes up vote 98 down vote accepted The scanner calls this function on end of file, so you can point it to another file and continue scanning its contents. If you don't need this, use %option noyywrap or link with -lfl to use the default yywrap() function in the library fl. share|improve this answer answered Nov 28 '09 at 0:42 hjhill 1,8041115 Thanks very much! –Nathan Campos Nov 28 '09 at 0:47 Very much appreciate this –JonnyRo Mar 29 '13 at 18:44 Simple, short, and to the point. Very helpful. –Filipe Goncalves Apr
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
Undefined Reference To `yywrap' Fedora
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Undefined Reference To Yywrap Windows
Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign yywrap function up flex: undefined reference to `yywrap' only when compiling/linking separately up vote 6 down vote favorite 2 I've been learning to use Flex (the lexical analyser) and I've been compiling with the following command: gcc -lfl -o test lex.yy.c and all is http://stackoverflow.com/questions/1811125/undefined-reference-to-yywrap well. However, I want to link it with other files, so I compile and link it separately with gcc -c lex.yy.c followed by gcc -lfl -o test lex.yy.o but gcc tells me that there is an undefined reference to yywrap(). So, what's going on here? I'm using Flex 2.5.35, gcc 4.7.2 and ld 2.22 c flex-lexer share|improve this question edited May 6 '13 at 16:45 Jens 36.4k863105 asked Dec 26 '12 at 15:54 Flukiluke 35113 4 did you try to add -lfl at http://stackoverflow.com/questions/14042903/flex-undefined-reference-to-yywrap-only-when-compiling-linking-separately the end instead of beginning? –Raj Dec 26 '12 at 15:55 That worked. Thanks! –Flukiluke Dec 28 '12 at 3:30 okay, i will post that as answer. –Raj Dec 28 '12 at 12:47 add a comment| 4 Answers 4 active oldest votes up vote 9 down vote accepted add -lfl at the end instead of beginning. share|improve this answer answered Dec 28 '12 at 12:47 Raj 1,47011840 add a comment| up vote 1 down vote Alternatively, if you don't want to use the library, just #define yywrap() 1 in your .l file, or provide a yywrap() method that returns 1. It's documented. share|improve this answer answered Jan 12 '13 at 2:17 EJP 197k17140249 add a comment| up vote 1 down vote Use gcc lex.yy.c -ll. Otherwise it will yield an undefined reference to yywrap. share|improve this answer edited Nov 4 '14 at 12:32 honk 3,221102544 answered Nov 4 '14 at 11:51 kartik7153 297 add a comment| up vote 0 down vote My solution was: sudo apt-get install flex share|improve this answer answered May 23 '13 at 13:02 Hugo 1,81811016 1 Please explain how you had already generated a lex.yy.c file without having flex already installed. –EJP Oct 4 '14 at 10:22 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard
[ date ] [ thread ] [ subject ] [ author ] http://www.cs.virginia.edu/pipermail/splint-discuss/2007-December/001085.html On Wed, 2007-12-12 16:57:07 +0530, Pramila V wrote: > Hi, > > I too got the below mentioned error. Open the respective file for example > csanner.c goto the function yywrap as given in error message. > > if ( yywrap() undefined reference ) > { > } > > Change this to as given below, > > if(yywrap) > { > } Um, what are you trying to do? You seem to replace a call to a function by the address of this undefined reference to function. I don't know what happens if the linker can't find yywrap(), but I *think* you used a very obscure (and non portable) way to write `if (0)' ... The right way to solve this problem was o to provide an (empty) yywrap() (see the flex man page), or o to link against libfl, or o to use `%option noyywrap' for flex. Ludolf -- --------------------------------------------------------------- Ludolf Holzheid Tel: +49 621 339960 Bihl+Wiedemann GmbH Fax: +49 621 3392239 Floßwörthstraße 41 e-mail: lholzheid at bihl-wiedemann.de D-68199 Mannheim, Germany --------------------------------------------------------------- Previous message: [splint-discuss] About 8051 sfr in Splint Next message: [splint-discuss] About onlytrans Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] More information about the splint-discuss mailing list