2012-03-19 13 views
1

私はANTLRで作成した簡単な文法をコンパイルしようとしていますが、リンクエラーが続いています。最後に、ANTLR文法をC++プロジェクトに組み込みたいのですが、C言語でのコンパイルとリンクがあればうれしいでしょう。私が最初に試した:ANTLR文法リンクエラー

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ドン不平を言う。私はライブラリを再インストールし、文法を再生成しました。これまでのところ運はありません。私はここで何かを見逃していますか? ありがとうございます!

答えて

2

コンパイラのコマンドの最後にライブラリを置く:

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

おかげでそんなに、それを知りませんでした! – yvesonline