[Flex-help] undefined reference to `yylex' when compiling as C++
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Filipp B. <b_...@zo...> - 2014-10-08 05:25:22
|
Hello. I am just starting with flex and trying to compile a simple program, no bison yet. /* calc.l */ %{ #include <iostream> #include <exception> %} %option debug %option nodefault %option noyywrap %option c++ %% \+ { std::cout << "PLUS" << std::endl; } \* { std::cout << "MULTIPLY" << std::endl; } - { std::cout << "MINUS" << std::endl; } \/ { std::cout << "DIVIDE" << std::endl; } .|\n { std::terminate(); } %% /* calc.l end */ The problem is the following: $ flex calc.l && g++ lex.yy.cc -lfl /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/../../../../lib64/libfl.a(libmain.o): In function `main': libmain.c:(.text.startup+0xb): undefined reference to `yylex' collect2: error: ld returned 1 exit status Writing pure C code using printf instead, with no %option c++, and compiling it with gcc works fine, but this doesn't. Why? -- Filipp B. |