[antlr-interest] Re: error : 'CharScanner.hpp:114: undefined reference' ... ???

rhalin rhalin at yahoo.com
Mon Aug 2 17:14:40 PDT 2004


checked on the config, and its finding it.  For reference, I 
installed antlr on a copy of slackware 9.0, it's only been up and 
running for a week, no preexisting version of antlr that I'm aware 
of, and no upgrades on the gcc or anything like that, went right from 
installing antlr to trying to compile my project, but no luck.  I'll 
keep poking around, see if I can come at something, thanks for the 
help!

-Rhalin

--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> On Mon, Aug 02, 2004 at 10:35:16PM -0000, rhalin wrote:
> > I'm having this exact same problem right now (many undefined 
> > references).  Antlr 2.7.2.  My grammer works in Windows Visual 
C++ 
> > just fine on Antlr 2.7.1, but when I port it over to Slackware 
Linux 
> > under KDevelop, I get errors just like this.  The examples 
compile.  
> > I'm compiling and linking to the library.  Not sure what else I 
could 
> > be missing.  Any help would be appreciated!
> 
> - check that both antlr library and project are built with the same 
version
>   of g++ (if more than one are installed or the version was 
upgraded)
> - verify that the antlr lib is built with the same #defines as the 
project
>   (I could suspect that this might be a case of getting problems 
with vtables)
> - verify that the antlr includes find antlrs config.hpp and not 
something
>   generated by autoconf. put a #warning or #error in it to check
> 
> KDevelop I don't know anything about more interesting is the 
underlying
> gcc/g++ version and the used binutils (ld)
> 
> If the examples of antlr compile and work then it's probably 
something
> obscure in the makefiles kdevelop generates.
> 
> Cheers,
> 
> Ric
> 
> > --- In antlr-interest at yahoogroups.com, "Oliver Haines" 
> > <xlrg2002 at y...> wrote:
> > > Hi,
> > > 
> > > I try to test antlr for c++. If I compile my simple app I get 
this 
> > errors:
> > > 
> > > cd "/home/graemer/Projekte/antlr/debug" && WANT_AUTOCONF_2_5="1"
> > > WANT_AUTOMAKE_1_6="1" make -k -j1  
> > > *make all-recursive 
> > > *Making all in src 
> > > *g++ -DHAVE_CONFIG_H -I. -I/home/graemer/Projekte/antlr/src -I..
> > > -I/usr/local/include -O0 -g3 -c
> > > /home/graemer/Projekte/antlr/src/antlr.cpp 
> > > */bin/sh ../libtool --mode=link g++ -O0 -g3 -L/usr/local/lib -
lantlr
> > > -o antlr antlr.o  
> > > *g++ -O0 -g3 -o antlr antlr.o -L/usr/local/lib -lantlr 
> > > *antlr.o(.text+0x24): In function `main': 
> > > */usr/local/include/antlr/CharScanner.hpp:114: undefined 
reference 
> > to
> > > `CalcLexer::CalcLexer[in-charge](std::basic_istream<char,
> > > std::char_traits<char> >&)' 
> > > *antlr.o
(.text+0x36):/usr/local/include/antlr/CharScanner.hpp:233:
> > > undefined reference to
> > > `CalcParser::CalcParser[in-charge](antlr::TokenStream&)' 
> > > *antlr.o
(.text+0x41):/usr/local/include/antlr/CharScanner.hpp:309:
> > > undefined reference to `CalcParser::expr()' 
> > > *antlr.o(.gnu.linkonce.t._ZN9CalcLexerD1Ev+0xb): In function
> > > `CalcLexer::~CalcLexer [in-charge]()': 
> > > */usr/local/include/antlr/CharScanner.hpp:241: undefined 
reference 
> > to
> > > `vtable for CalcLexer' 
> > > *antlr.o
(.gnu.linkonce.t._ZNK10CalcParser12getTokenNameEi+0x2c): In
> > > function `CalcParser::getTokenName(int) const': 
> > > */usr/local/include/antlr/CharScanner.hpp:163: undefined 
reference 
> > to
> > > `CalcParser::tokenNames' 
> > > *antlr.o
(.gnu.linkonce.t._ZNK10CalcParser13getTokenNamesEv+0x4): In
> > > function `CalcParser::getTokenNames() const': 
> > > */usr/local/include/antlr/CharScanner.hpp:240: undefined 
reference 
> > to
> > > `CalcParser::tokenNames' 
> > > *collect2: ld returned 1 exit status 
> > > *make[2]: *** [antlr] Error 1 
> > > *make[2]: Target `all' not remade because of errors. 
> > > *make[1]: *** [all-recursive] Error 1 
> > > *make: *** [all-recursive-am] Error 2 
> > > *make: Target `all' not remade because of errors. 
> > > **** Exited with status: 2 ***
> > > 
> > > 
> > > I'm using kdevelop 3 and linux.
> > > 
> > > the simple grammar:
> > > 
> > > options
> > > {
> > > language="Cpp";
> > > }
> > > 
> > > // Lexer
> > > class CalcLexer extends Lexer;
> > > 
> > > options {
> > >     k=2; // needed for newline junk
> > >     charVocabulary='\u0000'..'\u007F'; // allow ascii
> > > }
> > > 
> > > LPAREN: '(' ;
> > > RPAREN: ')' ;
> > > PLUS  : '+' ;
> > > MINUS : '-' ;
> > > STAR  : '*' ;
> > > INT   : ('0'..'9')+ ;
> > > WS    : ( ' '
> > >         | '\r' '\n'
> > >         | '\n'
> > >         | '\t'
> > >         )
> > >         {$setType(antlr::Token.SKIP);}
> > >       ;
> > > 
> > > // Parser
> > > class CalcParser extends Parser;
> > > 
> > > options {
> > >         buildAST=true;
> > > }
> > > 
> > > expr:   mexpr ((PLUS^|MINUS^) mexpr)*
> > >     ;
> > > 
> > > mexpr
> > >     :   atom (STAR^ atom)*
> > >     ;
> > > 
> > > atom:   INT
> > >     |   LPAREN! expr RPAREN!
> > >     ;
> > >     
> > > // AST-Walker
> > > class CalcTreeWalker extends TreeParser;
> > > 
> > > options {
> > >     importVocab=CalcLexer;
> > > }
> > > 
> > > expr returns [int r=0]
> > > { int a,b; }
> > >     :   #(PLUS  a=expr b=expr)  {r = a+b;}
> > >     |   #(MINUS a=expr b=expr)  {r = a-b;}   
> > >     |   #(STAR  a=expr b=expr)  {r = a*b;}
> > >     |   i:INT                   {r = atof(i->getText().c_str
());}
> > >     ;
> > > 
> > > Please help!
> > > thx,
> > > Oliver
> > 
> 
> -- 
> -----
+++++*****************************************************+++++++++---
----
>     ---- Ric Klaren ----- j.klaren at u... ----- +31 53 4893755  ----
> -----
+++++*****************************************************+++++++++---
----
>   "Of all the things I've lost I miss my mind the most --- Ozzy 
Osbourne



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list