如何在Windows上使用flex?

时间:2022-03-23 09:40:54

I'm trying to compile a project on windows and it uses flex/bison.

我正在尝试在Windows上编译项目,它使用flex / bison。

Compiling the flex and bison files went fine after I installed MinGW, but when I get to the final step of the build of:

安装MinGW后编译flex和bison文件很顺利,但是当我进入构建的最后一步时:

g++ -o hexciting CommandParser.tab.o CommandParser.yy.o Command.o -lfl

It says the library can't be found.

它说无法找到图书馆。

After some time on google, I tried changing the flag to -llibfl.a, but this library was also unable to be found.

在google上玩了​​一段时间后,我尝试将标志更改为-llibfl.a,但此库也无法找到。

How can I either get a copy of this library or build one myself?

我怎样才能获得这个库的副本或自己构建一个?

3 个解决方案

#1


Have you tried http://gnuwin32.sourceforge.net/packages/flex.htm ?

你试过http://gnuwin32.sourceforge.net/packages/flex.htm吗?

#2


I use flex via cygwin, and then compile in Visual Studio, to avoid having to link the library "l", you just need to define

我使用flex通过cygwin,然后在Visual Studio中编译,以避免必须链接库“l”,你只需要定义

int yywrap()

This function is called when the current file is finished, if yywrap return 0 a new file has been loaded, 1 when no more files exist.

当前文件完成时调用此函数,如果yywrap返回0则加载新文件,1当不存在更多文件时调用。

For another one of your questions I hard code yywrap to return 1, as it is taking input from standard-in verse files.

对于你的另一个问题,我硬编码yywrap返回1,因为它是从标准的经文文件中获取输入。

#3


Use Win flex-bison. It is very easy to use in Visual Studio.

使用Win flex-bison。它在Visual Studio中非常容易使用。

#1


Have you tried http://gnuwin32.sourceforge.net/packages/flex.htm ?

你试过http://gnuwin32.sourceforge.net/packages/flex.htm吗?

#2


I use flex via cygwin, and then compile in Visual Studio, to avoid having to link the library "l", you just need to define

我使用flex通过cygwin,然后在Visual Studio中编译,以避免必须链接库“l”,你只需要定义

int yywrap()

This function is called when the current file is finished, if yywrap return 0 a new file has been loaded, 1 when no more files exist.

当前文件完成时调用此函数,如果yywrap返回0则加载新文件,1当不存在更多文件时调用。

For another one of your questions I hard code yywrap to return 1, as it is taking input from standard-in verse files.

对于你的另一个问题,我硬编码yywrap返回1,因为它是从标准的经文文件中获取输入。

#3


Use Win flex-bison. It is very easy to use in Visual Studio.

使用Win flex-bison。它在Visual Studio中非常容易使用。