title: unresolved external symbol for yyparse()
body: <p>My main.cpp looks like this:</p>
  
  <pre><code>#include &lt;assert.h&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include "astgen.h"
  #include "astexec.h"
  
  extern int yyparse();
  extern FILE *yyin;
  
  int main()
  {
      //yydebug = 0;
      struct AstElement *a = 0;
      FILE *fp ;
      fopen_s(&amp;fp,"example.txt","r");
      //std::cout&lt;&lt;fp;
      if (fp==NULL)
      {
          std::cout&lt;&lt;"error";
      }
      yyin=fp;
      yyparse();
  
      assert(a);
      struct ExecEnviron* e = createEnv();
      execAst(e, a);
      freeEnv(e);
      /* TODO: destroy the AST */
  }
  </code></pre>
  
  <p>When I try to compile this, I get the error: main.obj : error <code>LNK2019: unresolved external symbol "int __cdecl yyparse(void)" (?yyparse@@YAHXZ) referenced in function _main</code></p>
  
  <p>I am a newbie in flex/bison. Any help would be appreciated. 
  If it helps here is my parser.y file: </p>
  
  <pre><code>%error-verbose /* instruct bison to generate verbose error messages*/
  %{
  #include "astgen.h"
  #define YYDEBUG 1
  
  /* Since the parser must return the AST, it must get a parameter where
   * the AST can be stored. The type of the parameter will be void*. */
  #define YYPARSE_PARAM astDest
  extern int yylex();
  %}
  
  %union {
      int val;
      char op;
      char* name;
      struct AstElement* ast; /* this is the new member to store AST elements */
  }
  
  %token TOKEN_BEGIN TOKEN_END TOKEN_WHILE TOKEN_DO
  %token&lt;name&gt; TOKEN_ID
  %token&lt;val&gt; TOKEN_NUMBER
  %token&lt;op&gt; TOKEN_OPERATOR
  %type&lt;ast&gt; program block statements statement assignment expression whileStmt call
  %start program
  
  %{
  /* Forward declarations */
  void yyerror(const char* const message);
  
  
  %}
  
  %%
  
  program: statement';' { (*(struct AstElement**)astDest) = $1; };
  
  block: TOKEN_BEGIN statements TOKEN_END{ $$ = $2; };
  
  statements: {$$=0;}
      | statements statement ';' {$$=makeStatement($1, $2);}
      | statements block';' {$$=makeStatement($1, $2);};
  
  statement: 
        assignment {$$=$1;}
      | whileStmt {$$=$1;}
      | block {$$=$1;}
      | call {$$=$1;}
  
  assignment: TOKEN_ID '=' expression {$$=makeAssignment($1, $3);}
  
  expression: TOKEN_ID {$$=makeExpByName($1);}
      | TOKEN_NUMBER {$$=makeExpByNum($1);}
      | expression TOKEN_OPERATOR expression {$$=makeExp($1, $3, $2);}
  
  whileStmt: TOKEN_WHILE expression TOKEN_DO statement{$$=makeWhile($2, $4);};
  
  call: TOKEN_ID '(' expression ')' {$$=makeCall($1, $3);};
  
  %%
  
  #include "astexec.h"
  #include &lt;stdlib.h&gt;
  
  void yyerror(const char* const message)
  {
      fprintf(stderr, "Parse error:%s\n", message);
      exit(1);
  }
  </code></pre>
  
  <p><strong>EDIT 1:</strong> I am using winflexbison in VS 2012 environment to generate my parser and the lexer. The process for the build is rather simple. All that is required to be done is to add the <code>&lt;appropriate&gt;_custom_build.targets</code> to <strong>build customizations</strong> for the <strong>project</strong> in VS and just build solution. A reference to the documentation can be found here @ <a href="http://sourceforge.net/p/winflexbison/wiki/Visual%20Studio%20custom%20build%20rules/" rel="nofollow">winflexbison for Visual studio</a>.</p>
  
  <p>I would also like to point out that I followed the same method to build a sample flex and bison file and later integrated in a project. That worked fine for me. </p>
  
  <p>What am I doing wrong here?</p>