gpt4 book ai didi

c++ - ANTLR语法链接错误

转载 作者:行者123 更新时间:2023-11-30 04:28:52 26 4
gpt4 key购买 nike

我正在尝试编译一个我用 ANTLR 创建的简单语法,但我不断收到链接错误。最后,我想在 C++ 项目中包含 ANTLR 语法,但现在如果 C 中的编译和链接工作正常,我会很高兴。我第一次尝试:

g++ -oX -I/usr/local/include -I../src -L/usr/local/lib -lantlr3c \
../src/RtfLexer.cpp \
../src/RtfParser.cpp

然后我尝试了:

gcc -oX -lantlr3c -I../src ../src/RtfLexer.cpp ../src/RtfParser.cpp

但我不断得到:

/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不报错。我重新安装了库,重新生成了语法,到目前为止没有运气。我在这里遗漏了一些明显的东西吗?提前致谢!

最佳答案

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

g++ -oX -I../src ../src/RtfLexer.cpp ../src/RtfParser.cpp -lantlr3c

关于c++ - ANTLR语法链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9770138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com