Ask Your Question
0

Can you explain the "undefined reference to 'yylex'" error that arose while compiling with g++?

asked 2021-05-30 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-10-12 22:00:00 +0000

qstack gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-30 11:00:00 +0000

Seen: 10 times

Last updated: Oct 12 '22