Chinaunix首页 | 论坛 | 博客
  • 博客访问: 146930
  • 博文数量: 43
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 401
  • 用 户 组: 普通用户
  • 注册时间: 2013-07-31 22:55
文章分类

全部博文(43)

文章存档

2015年(1)

2014年(25)

2013年(17)

我的朋友

分类: Windows平台

2014-02-18 11:46:17

 

This tutorial is for users who are already familiar with Visual Studio VC++ and flex.

  1. Create a new workspace and add your lex file (ie lexer.l)

  2. Save the following files in the same directory as your workspace:  , , 

  3. Go to Project/Settings/ and select your project in the explorer window at the left.

  4. Select the Link tab. In the "Object/library modules" section, append libfl.lib and libfl.a to the end of the list. 

  5. If your lex file reads input from the command line, (such as a filename like inputfile.txt), then select the Debug tab and add the command line parameters to the "Program Arguments" field.

  6. Return to the left hand explorer window and expand your project. Select your lex file (ie lexer.l)

  7. Under the "General" tab, select Always use custom build step.

  8. Under the "Custom Build" tab, place flex followed by the name of your lexer file into the "Commands" box (ie flex lexer.l)
    Then place this text into the "Outputs" box:      lex.yy.c

  9. Build your project once (Control-F5). You should get the message "Cannot execute program".

  10. The previous step should create a file called lex.yy.c in your workspace directory. Add this file to your project.

  11. I suggest you add the input file (if your lex program requires one) to your project as well so that you can easily edit it, but this is not required.

  12. If you get an error that looks something like: 

    lex.yy.obj : error LNK2001: unresolved external symbol _yywrap
    Debug/compiler.exe : fatal error LNK1120: 1 unresolved externals

    This means you are not linking in the library files correctly. Check step 2, 3, and 4 again.

  13. The next time you build (Control-F5), your project should run. If it doesn't,  and I'll see if I can help.
阅读(1502) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~