[antlr-interest] compiling examples with the C target

Jim Idle jimi at temporal-wave.com
Wed Jul 14 17:59:21 PDT 2010


Did you read the documentation? Assuming you have installed the C runtime correctly, you need

gcc -I. *.c -lantlr3c

The -I. means look in the current directory for include files. It will already look in /usr/include for the installed antlr includes.

Also, remember http://antlr.markmail.org 

You can and should use java -jar and not -cp with 3.2 too.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Drew Shaw
> Sent: Wednesday, July 14, 2010 5:55 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] compiling examples with the C target
> 
> I am having trouble with the using the C target.  I downloaded the C
> examples and ran
> java -cp /usr/local/antlr/antlr-3.2.jar
>  in the directory of one of the example directories.  This produced the
> parser and lexer files as expected. I tried compiling the examples
> using
> gcc *.c -I/usr/local/include -L/usr/local/lib -o arbitrary
> I got some errors regarding missing header files.
> I fixed this by repalcing the angle brackets in the files with quotes
> so the
> header files could be found in the current directory.  After this I
> tried to
> compile the project once again and got the following.
> 
> drew at ubuntu:~/Desktop/examples-v3/C/island-grammar$ gcc *.c
> -I/usr/local/include
> -L/usr/local/lib -o ff
> /tmp/ccyVyMvd.o: In function `callJavadoc':
> javadocctl.c:(.text+0x3a): undefined reference to
> `antlr3CommonTokenStreamSourceNew'
> /tmp/cc75UF4Q.o: In function `JavadocLexerNewSSD':
> JavadocLexer.c:(.text+0x8d): undefined reference to
> `antlr3LexerNewStream'
> /tmp/ccOb1COu.o: In function `JavadocParserNewSSD':
> JavadocParser.c:(.text+0x7a): undefined reference to
> `antlr3ParserNewStream'
> /tmp/ccfeeQI8.o: In function `main':
> main.c:(.text+0x39): undefined reference to `antlr3AsciiFileStreamNew'
> main.c:(.text+0xd8): undefined reference to
> `antlr3CommonTokenStreamSourceNew'
> /tmp/cc2S4tNM.o: In function `callSimple':
> simplectl.c:(.text+0x3a): undefined reference to
> `antlr3CommonTokenStreamSourceNew'
> /tmp/ccxtwI9q.o: In function `SimpleLexerNewSSD':
> SimpleLexer.c:(.text+0x8d): undefined reference to
> `antlr3LexerNewStream'
> /tmp/ccXvuQL5.o: In function `SimpleParserNewSSD':
> SimpleParser.c:(.text+0x7d): undefined reference to
> `antlr3ParserNewStream'
> collect2: ld returned 1 exit status
> drew at ubuntu:~/Desktop/examples-v3/C/island-grammar$ ls
> input                         javadoc.h        main.c
> SimpleLexer.h
> islandfuncs.h                 JavadocLexer.c   output
> SimpleParser.c
> island-grammar.vcproj         JavadocLexer.h   simplectl.c
> SimpleParser.h
> island-grammar.vcproj.vspscc  JavadocParser.c  Simple.g
> Simple.tokens
> javadocctl.c                  JavadocParser.h  simple.h
> Javadoc.g                     Javadoc.tokens   SimpleLexer.c
> 
> Dose anyone have any suggestions about things to try to get rid of
> these
> errors?
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list