如何在Windows环境下使用Bison编译yacc(.y)文件?
我读过 http://dinosaur.compilertools.net/bison/bison_5.html#SEC25 。但是按照这些说明,我无法使用 bison
编译我的 yacc 文件
如何在 Windows 7 中编译我的文件...?
请帮助我做到这一点。
I've read http://dinosaur.compilertools.net/bison/bison_5.html#SEC25. But following those instruction i can not compile my yacc file using bison
How do i compile my file in windows 7 ... ?
Please help me to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
bison 无法在 Windows 上正常运行的一个常见原因在安装说明中有所提及,但经常被忽视。重要的是,bison(和 flex)安装的目录位置名称(路径)不包含空格。特别是,这意味着它不能放置在
C:\Program Files\
下。问题是该目录可能会被建议作为默认安装位置。有时需要手动将默认值更改为其他内容(例如C:\GnuWin\
或类似内容)。通常还需要手动将适当的目录添加到 PATH 环境变量中。完成此操作后,从命令提示符运行 bison 和 flex 应该不会出现问题。它通常按以下方式使用:没有必要安装 MinGW、Cygwin 或使用 Powershell 或 VM 或使用 linux,如 @DavidHefferman 所示
如果您仍然无法正确使用,我什至有一个 教学视频!
There is a common reason why bison will not operate properly on Windows and is mentioned in the install instructions but often overlooked. It is important that the name of the location of the directory that bison (and flex) is installed in (the path) does not contain a space. in particular this means that it cannot be placed under
C:\Program Files\
. The problem is that this directory might be suggest as the default install location. It is sometimes necessary to manually change the default to somethings else (likeC:\GnuWin\
or similar). It is also usually necessary to manually add the appropriate directory to the PATH environment variable. Once this has been done there should be no problems in running bison and flex from the command prompt. It would normally be used in the following way:It is not necessary to install MinGW, Cygwin or use Powershell or a VM or use linux as indicated by @DavidHefferman
If you still can't get it right, I even have an instructional video!
在 Windows PowerShell 中使用这些 Unix 命令可能可以工作,但我不确定,而且我目前不在 Windows 上,所以我无法检查它。
如果失败,您可以尝试安装 Cygwin (Windows 中的基本 Linux 环境)。您必须在安装过程中选择 bison 软件包。它带有自己的外壳可供您使用。
实际上,我个人在 Windows 下编程时最喜欢的是使用 VirtualBox 设置虚拟机。这样您就可以使用真正的 Linux 环境,而无需真正离开 Windows。
祝你好运!
Using those Unix commands in Windows PowerShell might work, but I'm not sure and I'm currently not on Windows, so I can't check it.
If that fails you could try installing Cygwin (a basic Linux environment in Windows). You'd have to select the bison package during installation. It comes with its own shell that you can use.
Actually my personal favorite when programming under Windows is setting up a virtual machine with VirtualBox. That way you could use a real Linux environment without actually leaving Windows.
Good luck!