Antlr C运行时中的未定义引用示例
Undefined References In Antlr C Runtime Example
我有一个问题运行C运行时的例子在http://www.antlr.org/depot/examples-v3/C/treeparser从Antlr
我已经从http://www.antlr.org/download/C下载并安装了C运行时。图书馆图书馆。A位于/usr/local/lib中,antlr头位于/usr/local/include中。这是鹿角图书馆吗?在其他示例中,我看到提到的"antlr3c"库,而我的前面有"lib"。
我下载了示例文件,并将它们放在/home/frazer/examples的一个名为"example"的文件夹中然后让Antlr创建自动生成的解析器和Lexer文件,从那里运行:
gcc *.c -o test -I. -L -llibantlr3c
,它给了我以下错误:
/tmp/ccvXlH3T.o: In function `LangDumpDeclNewSSD':
LangDumpDecl.c:(.text+0x89): undefined reference to `antlr3TreeParserNewStream'
/tmp/cc3TwzKz.o: In function `LangLexerNewSSD':
LangLexer.c:(.text+0xd3): undefined reference to `antlr3LexerNewStream'
/tmp/ccpfbaFf.o: In function `LangParserNewSSD':
LangParser.c:(.text+0x8c): undefined reference to `antlr3ParserNewStream'
LangParser.c:(.text+0xf1): undefined reference to `ANTLR3_TREE_ADAPTORNew'
LangParser.c:(.text+0x103): undefined reference to `antlr3VectorFactoryNew'
/tmp/ccpfbaFf.o: In function `decl':
LangParser.c:(.text+0x6ca): undefined reference to `antlr3RewriteRuleSubtreeStreamNewAE'
LangParser.c:(.text+0x76f): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
LangParser.c:(.text+0x811): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
LangParser.c:(.text+0x85d): undefined reference to `antlr3RewriteRuleSubtreeStreamNewAEE'
/tmp/ccED3tJV.o: In function `main':
main.c:(.text+0x46): undefined reference to `antlr3AsciiFileStreamNew'
main.c:(.text+0xe0): undefined reference to `antlr3CommonTokenStreamSourceNew'
main.c:(.text+0x1d0): undefined reference to `antlr3CommonTreeNodeStreamNewTree'
collect2: ld returned 1 exit status
我之前唯一使用Antlr的经验是在Java中,而我之前唯一使用C/c++的经验是在Visual Studio中,所以我对链接和命令行编译等都是新手。所以我猜这是一个非常简单的错误,涉及错误的链接,或者错误的antlr库。
提前道歉和感谢。
您正在使用不带参数的-L选项。选项-llibantlr3c被视为-L的目录参数,而不是要链接的库。因为链接中没有包含antlr库,所以您将获得所有缺失的符号。另外,-l在库名前加上'lib',所以试试
gcc *.c -o test -I. -lantlr3c
如果libantlr3c 。如果文件位于非标准目录中,则使用-L标志添加该目录
在版本3.4之后,请更改为input = antlr3FileStreamNew ((antlr3_uint8)argv[1], ANTLR3_ENC_8BIT);
Not, antlr3AsciiFileStreamNew(argv[1])为例参考中松真司http://www.antlr.org/wiki/display/ANTLR3/Five +分钟+简介+ + ANTLR + 3
- 编译C++时未定义的引用
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 未定义的引用在哪里
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 对 Scalar ::Scalar() 的未定义引用
- 已定义函数时出现 G++ "未定义的引用"错误
- 链接 cmake 时出现未定义的引用错误
- 对复制 CTOR 和 CTOR 的未定义引用
- 错误:未定义对'oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)'的引用
- 右值引用未定义的行为
- 对"vtable for DigitalClock"的未定义引用 - 未定义对"DigitalClock::staticMetaObject"的引用 - Qt
- 函数类型到函数类型的引用:未定义的引用
- avcodec_alloc_context引用未定义,但ffmpeg链接顺序正确
- 从c++调用Fortran子程序,链接时引用未定义
- 枚举引用未定义,但位于包含的头文件中