Undefined reference to `yylex'
<p>I am trying to parse one input file using flex and bison but I am facing one difficulty while compiling my program. I am attaching my flex and bison code and error which I am getting.</p>

<p>Please help me out to solve these errors</p>

<p><strong>lex.l</strong></p>

<pre><code>%{
 #include &lt;iostream&gt;  
 #include &lt;stdio.h&gt;
#include "yacc.tab.h"
 #define YY_DECL extern "C" int yylex()

using namespace std;  


%}

DOT             "."  
COLON           ":"  
SEMICOLON       ";"  
COMMA           ","  
ANGLE_LEFT      "&lt;"  
ANGLE_RIGHT     "&gt;"  
AT              "@"  
EQUAL           "="  
SQUARE_OPEN     "["  
SQUARE_CLOSE    [^\\]"]"  
OPENBRACE       "\("  
CLOSEBRACE      "\)"  
QUOTE           "\""  
QUOTE_OPEN      "\""  
QUOTE_CLOSE     [^\\]"\""  
SPACE           " "  
TAB             "\t"  
CRLF            "\r\n"  
QUOTED_PAIR     "\\"[^\r\n]  
DIGIT           [0-9]  
ALPHA           [a-zA-Z]  
QTEXT           [0-9a-zA-Z!#$%&amp;'()*+,\-.\/:;&lt;=&gt;?@\[\]^_`{|}~]  

%%

[a-zA-Z0-9]+            { yylval.sval = strdup(yytext); return TOK_STRING; }

{SPACE}*                    {return TOK_SPACE; }

{SPACE}*Name.*              {return TOK_NAME; }  
{SPACE}*SIZE.*              {return TOK_SIZE; }  
{SPACE}*ITERATE.*           {return TOK_ITERATE; }  
{SPACE}*DIRECTION.*     {return TOK_DIRECTION; }  

^{CRLF}                         { return TOK_EMPTY_LINE; }  
{CRLF}                          {}  
.                               {}/* ignore unknown chars */  
</code></pre>

<p><strong>yacc.y</strong></p>

<pre><code> %{
 #include &lt;cstdio&gt; 
 #include &lt;cstring&gt;
 #include &lt;iostream&gt;
 #include &lt;stdio.h&gt;

using namespace std;

extern "C" int yylex();  
extern "C" FILE *yyin;

void yyerror(const char* s);  


%}

%union  
{  
    char* sval;  
};  

%token &lt;sval&gt; TOK_NAME  
%token &lt;sval&gt; TOK_SIZE  
%token &lt;sval&gt; TOK_STRING  
%token &lt;sval&gt; TOK_ITERATE  
%token &lt;sval&gt; TOK_DIRECTION  


%token TOK_SPACE  


%%

str:  
    TOK_SPACE TOK_NAME TOK_SPACE TOK_STRING   
    {  
        cout &lt;&lt; "Value:" &lt;&lt; $2 &lt;&lt; "-&gt;" &lt;&lt; $4;  
    }  
    ;  
%%  

int main(void) {  
    FILE * pt = fopen("new file ", "r" );  
    if(!pt)  
    {  
    cout &lt;&lt; "Bad Input.Noexistant file" &lt;&lt; endl;  
    return -1;  
    }  
    yyin = pt;  
    do  
    {  
        yyparse();  
     }while (!feof(yyin));        
}  
void yyerror(const char *s)  
{  
   cout &lt;&lt; "Error. " &lt;&lt; s &lt;&lt; endl;   
   exit(-1);     
}  
</code></pre>

<p>I build these using:</p>

<pre><code>flex bas.l 
bison -d yacc.y 
g++ lex.yy.c yacc.tab.c -lfl -o scanner.exe 
</code></pre>

<p>While compiling program I found following errors:</p>

<blockquote>
  <p>/tmp/cceIyDkD.o: In function `main':<br>
  yacc.tab.c:(.text+0x708): multiple definition of `main'<br>
  /tmp/ccatq95p.o:lex.yy.c:(.text+0x1228): first defined here<br>
  /usr/bin/ld: Warning: size of symbol `main' changed from 86 in /tmp/ccatq95p.o to 120 in /tmp/cceIyDkD.o<br>
  /tmp/cceIyDkD.o: In function `yyparse()':<br>
  yacc.tab.c:(.text+0x2d6): undefined reference to `yylex'<br>
  collect2: ld returned 1 exit status </p>
</blockquote>

<p>Please help me out</p>