小编Ale*_*rie的帖子

Flex 和 Bison GCC 编译错误,ld:找不到 -lfl 的库

在为简单扫描仪编译 flex 和 bison 源时,我遇到以下错误:

$ gcc -o lab5 lab5.tab.c lex.yy.c -lfl
ld: library not found for -lfl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

lex源代码:

%{

#include <stdio.h>
#include <string.h>
#include "lab5.tab.h"
void showError();
%}

integer (\+?[1-9][0-9]*)
id ([a-zA-Z_][a-zA-Z0-9_]*)

%%

{id} {sscanf(yytext, "%s", yylval.name); return ID;}
{integer} {yylval.number = atoi(yytext); return INT;}
";" return SEMICOLON;
. {showError(); return OTHER;}

%%

void showError() {
    printf("Other input");
}
Run Code Online (Sandbox Code Playgroud)

野牛源代码:

%{
    #include <stdio.h>
    int yylex(); …
Run Code Online (Sandbox Code Playgroud)

c gcc bison

1
推荐指数
1
解决办法
453
查看次数

标签 统计

bison ×1

c ×1

gcc ×1