I am testing and playing a bit with flex before I start using it for a real project, but I am facing sone issues.
I am working on Android using a Linux emulator named Termux. I've installed flex and clang executing respectively $ apt install flex
and $ apt install clang
.
I have noticed that if I write flex code for C, process it with $ flex filename
, and then compile it with $ gcc -lfl lex.yy.c
, everything compiles and the binary works perfectly.
But if I write flex code for C++ (i.e. using C++ only features), process it with $ flex -+ filename
and compile it with $ g++ -lfl lex.yy.cc
, during compilation an error pops out saying that a file FlexLexer.h
, included as
#include <FlexLexer.h>
was not found.
Why does this only happen when using C++? Since I actually need it for C++, how can I fix this issue, minding that I am working on Android using an emulator?
This was a bug in the flex
package in Termux and has now been fixed - run apt update && apt upgrade
to get the updated package which contains FlexLexer.h
.