首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ANTLR语法链接错误

ANTLR语法链接错误
EN

Stack Overflow用户
提问于 2012-03-19 20:24:00
回答 1查看 602关注 0票数 1

我试图编译一个我用ANTLR创建的简单语法,但我总是得到链接错误。最后,我想把ANTLR语法包含在一个C++项目中,但是现在,如果能用C编译和链接,我会很高兴的。我第一次尝试:

代码语言:javascript
复制
g++ -oX -I/usr/local/include -I../src -L/usr/local/lib -lantlr3c \
../src/RtfLexer.cpp \
../src/RtfParser.cpp

然后我试着:

代码语言:javascript
复制
gcc -oX -lantlr3c -I../src ../src/RtfLexer.cpp ../src/RtfParser.cpp

但我一直在想:

代码语言:javascript
复制
/tmp/ccJgJxMH.o: In function `RtfLexerNewSSD':
RtfLexer.cpp:(.text+0xb0): undefined reference to `antlr3LexerNewStream'
/tmp/ccVZ2Vco.o: In function `RtfParserNewSSD':
RtfParser.cpp:(.text+0x7d): undefined reference to `antlr3ParserNewStream'
RtfParser.cpp:(.text+0xfa): undefined reference to `ANTLR3_TREE_ADAPTORNew'
RtfParser.cpp:(.text+0x10e): undefined reference to `antlr3VectorFactoryNew'
/tmp/ccVZ2Vco.o: In function `plaintext(RtfParser_Ctx_struct*)':
RtfParser.cpp:(.text+0x8c4): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
RtfParser.cpp:(.text+0x992): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
RtfParser.cpp:(.text+0xa60): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
RtfParser.cpp:(.text+0xb2e): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
RtfParser.cpp:(.text+0xbfc): undefined reference to `antlr3RewriteRuleTOKENStreamNewAE'
[more to follow]

所以看起来图书馆找不到了,但g++和gcc并不抱怨。我重新安装了库,重新生成了语法,到目前为止还没有成功。我是不是漏掉了什么明显的东西?提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-19 20:26:01

将库放在编译器命令的末尾:

代码语言:javascript
复制
g++ -oX -I../src ../src/RtfLexer.cpp ../src/RtfParser.cpp -lantlr3c
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9770138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档