Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The "undefined reference to 'yylex'" error is usually encountered during compilation with g++ when the compiler cannot find the implementation of the function 'yylex' that was declared in a lexer file or a flex-generated C++ file. This function is the entry point for the lexer generated by Flex (a lexical analyzer generator) and is responsible for scanning the input stream and returning the next token to the parser.

The error occurs when the compilation process encounters a reference to the 'yylex' function but cannot find its implementation. This can happen when the lexer file is not included in the compilation process, or when the file containing the implementation of 'yylex' is not linked properly.

To fix this error, you need to ensure that the lexer file is included in the compilation process and that the file containing the implementation of 'yylex' is properly linked. This can be done by adding the relevant files to the compilation command or by modifying the Makefile.