Search code examples
cbisonyaccpow

undefined reference to `pow' in yyparse


I have include math.h in my .yacc file and when I am trying to use the pow function in this part of the code it is giving me the above mentioned error

expression2:expression2 POWER_OP expression3  {/*keeping POWER_OP at highest precedence*/ $$ = pow($1,$3);}

and when I tried to put 2,3 or any constant value in the same part of code it is working fine


Solution

  • Try adding -lm when compiling the files. example: gcc c.tab.c lex.yy.cc -lm