我试图编译一个我用ANTLR创建的简单语法,但我总是得到链接错误。最后,我想把ANTLR语法包含在一个C++项目中,但是现在,如果能用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并不抱怨。我重新安装了库,重新生成了语法,到目前为止还没有成功。我是不是漏掉了什么明显的东西?提前感谢!
发布于 2012-03-19 20:26:01
将库放在编译器命令的末尾:
g++ -oX -I../src ../src/RtfLexer.cpp ../src/RtfParser.cpp -lantlr3chttps://stackoverflow.com/questions/9770138
复制相似问题