我下载了源代码并想编译扫描程序文件.它会产生以下错误:
[meepo@localhost cs143-pp1]$ gcc -o lex.yy.o lex.yy.c -ll
In file included from scanner.l:15:0:
scanner.h:59:5: error: unknown type name ‘bool’
In file included from scanner.l:16:0:
utility.h:64:38: error: unknown type name ‘bool’
utility.h:74:1: error: unknown type name ‘bool’
In file included from scanner.l:17:0:
errors.h:16:18: fatal error: string: No such file or directory
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同的编译器来编译它,但它出现了不同的错误.
[meepo@localhost cs143-pp1]$ g++ -o scan lex.yy.c -ll
/usr/bin/ld: cannot find -ll
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我的操作系统是3.0-ARCH,我不知道为什么会这样.我该如何修复错误?
use*_*122 120
C90不支持布尔数据类型.
C99确实包括它包括:
#include <stdbool.h>
Run Code Online (Sandbox Code Playgroud)
小智 51
如果你有,C99会这样做
#include <stdbool.h>
Run Code Online (Sandbox Code Playgroud)
如果编译器不支持C99,您可以自己定义:
// file : myboolean.h
#ifndef MYBOOLEAN_H
#define MYBOOLEAN_H
#define false 0
#define true 1
typedef int bool; // or #define bool int
#endif
Run Code Online (Sandbox Code Playgroud)
(但请注意,此定义更改了类型的ABI,bool
因此链接到使用正确定义编译的外部库bool
可能会导致难以诊断的运行时错误).
只需添加以下内容:
#define __USE_C99_MATH
#include <stdbool.h>
Run Code Online (Sandbox Code Playgroud)
在您的代码中的某处有一行#include <string>
。这本身就告诉您程序是用 C++ 编写的。所以使用g++
比gcc
.
对于丢失的库:如果你能找到一个名为libl.so
. 使用locate
命令 try /usr/lib
、/usr/local/lib
、/opt/flex/lib
或使用 brute-force find / | grep /libl
。
找到文件后,必须将目录添加到编译器命令行,例如:
g++ -o scan lex.yy.c -L/opt/flex/lib -ll
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
168341 次 |
最近记录: |