“Undefined symbols for architecture x86_64:” when compiling lex and yacc-Collection of common programming errors

Lex and Yacc work, but when I try to compile the y.tab.c file, I’m getting the following error. I have a feeling its a linking issue where compiler can’t find the library that it needs, but I have no idea how to fix it.

In my nor.y file, I have this at the top:

%{
#include 
%}

In my nor.l file, I have this at the top:

 %{
#include "y.tab.h"
#include 
extern YYSTYPE yylval;
%}

Then, when I try to compile with

gcc y.tab.h -ly -ll

I get the error:

Undefined symbols for architecture x86_64:
  "_yyparse", referenced from:
  _main in liby.a(main.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Originally posted 2013-11-09 22:44:25.