我有一個簡單的「語言」,我使用的Flex(詞法分析器),它是這樣的:未定義的引用yywrap
/* 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();
printf("%8d%8d%8d\n", lines, words, chars);
}
在我運行一個flex count.l
,都沒有錯誤或警告變爲正常,然後當我嘗試做一個cc lex.yy.c
我得到這個錯誤:
Ubuntu的@ EeePC的:〜/桌面$ CC的lex.yy.c
/tmp/ccwwkhvq.o:在功能yylex': lex.yy.c:(.text+0x402): undefined reference to
yywrap」
/TMP/ccwwkhvq.o:在功能input': lex.yy.c:(.text+0xe25): undefined reference to
yywrap」
collect2:LD返回1退出狀態
有什麼不對?
非常感謝! – 2009-11-28 00:47:23
非常感謝這 – JonnyRo 2013-03-29 18:44:44
簡單,簡短,並重點。很有幫助。 – 2014-04-29 19:16:47