致命错误:FlexLexer。h:没有这样的文件或目录

时间:2021-11-06 09:40:21

I created a simple Flex file to read and return tokens from a file. I generated the scanner file using the command flex -c++ scanner.l. When trying to compile the generated lex.yy.cc file I am getting the error as:

我创建了一个简单的Flex文件来读取和返回文件中的令牌。我使用命令flex -c++ scanner.l生成扫描仪文件。当尝试编译生成的lex.yy时。我收到的cc文件错误为:

Fatal error: FlexLexer.h: No such file or directory

The include folder of flex contains the FlexLexer.h file. I also tried by copying the file to the same folder where lex.yy.cc resides. Still the error exists.

flex的include文件夹包含FlexLexer。h文件。我还尝试将文件复制到lex.yy的同一个文件夹中。cc驻留。仍然存在的错误。

I am using Windows7.

我用Windows7多。

How can I solve this problem. Thank You

我怎样才能解决这个问题呢?谢谢你!

1 个解决方案

#1


1  

The generated scanner uses the line:

生成的扫描器使用行:

#include <FlexLexer.h>

which means that the FlexLexer.h file will be searched for in system include directories. If you correctly install flex, the installation should put the FlexLexer.h file in some system include directory. If you just download the flex source and compile it without installing it, that won't work. And it might not work in the Windows environment either; I've never tried.

这意味着FlexLexer。h文件将在系统包含目录中搜索。如果您正确安装flex,安装应该安装FlexLexer。某些系统中的h文件包含目录。如果您只是下载flex源代码并在不安装它的情况下编译它,那将无法工作。它可能在Windows环境中也不适用;我从来没有试过。

If you have no other alternative, and you're using gcc, you can tell gcc to use the include directory in the flex source tree as a system include directory using the command-line option -isystem /path/to/flex/include. There's almost certainly a VS2010 equivalent but I have no idea what it is.

如果您没有其他选择,并且正在使用gcc,您可以告诉gcc使用flex源代码树中的include目录作为系统包含目录,使用命令行选项-isystem /path/to/flex/include。几乎可以肯定会有VS2010版本,但我不知道它是什么。

#1


1  

The generated scanner uses the line:

生成的扫描器使用行:

#include <FlexLexer.h>

which means that the FlexLexer.h file will be searched for in system include directories. If you correctly install flex, the installation should put the FlexLexer.h file in some system include directory. If you just download the flex source and compile it without installing it, that won't work. And it might not work in the Windows environment either; I've never tried.

这意味着FlexLexer。h文件将在系统包含目录中搜索。如果您正确安装flex,安装应该安装FlexLexer。某些系统中的h文件包含目录。如果您只是下载flex源代码并在不安装它的情况下编译它,那将无法工作。它可能在Windows环境中也不适用;我从来没有试过。

If you have no other alternative, and you're using gcc, you can tell gcc to use the include directory in the flex source tree as a system include directory using the command-line option -isystem /path/to/flex/include. There's almost certainly a VS2010 equivalent but I have no idea what it is.

如果您没有其他选择,并且正在使用gcc,您可以告诉gcc使用flex源代码树中的include目录作为系统包含目录,使用命令行选项-isystem /path/to/flex/include。几乎可以肯定会有VS2010版本,但我不知道它是什么。