[antlr-interest] Working recipe to build antlr in Cygwin environment

Ashish Aggarwal ashish at noida.atrenta.com
Mon Nov 24 19:44:06 PST 2003


Hi frends,
   As every new user do face problems in building antlr on windows, 
using cygwin/java/gcc, I (on behalf of our company, atrenta) , would 
like to share with you all this working recipe on "How To Build Antlr On 
Cygwin".

If any one of you have any suggestion for modifications in it, do let me 
know.
Else, I would like the owner of this group , Terence, to kindly put the 
same on the website www.antlr.org

Cheers
Ashish

############################################################################
Here is the working recipe, repeated until it works exactly from a clean 
install every time with no redo
Environment:
Windows 2000:

cygwin:
1.5.5.1
 which has problems with gcc and cpp (and configure fails with)
mingw :
MinGW-3.1.0-1.exe
(do not forget to rename make.exe to mingw32-make.exe, as it cannot cope 
with the ANTLR Makefile!, but the cygwin one can)

path in cygwin to use mingw first
PATH="/mingw/bin:/usr/local/bin:/usr/bin:/bin:$PATH"

java SDK:
j2sdk-1_4_2-nb-3_5_1-bin-windows.exe

antlr:
antlr-2.7.2.tar.gz

1.Untar anltr into a new directory under cygwin <basedir>
{mine is C:\cygwin\redo\antlr-2.7.2, under cycgwin its /redo/antlr-2.7.2}
Do NOT add antlr.jar  to your $CLASSPATH environment, as it is not a 
valid file yet.

2. Note that <basedir>/configure contains an error at
# Java

CLASSPATH=$CLASSPATH:.
 just comment it out, as we set the . in the external CLASSPATH
#CLASSPATH=$CLASSPATH:.

3. set up class path for configure
 note the . in the path
        the ; path seperator
        the windows file format.
      These are because Java j2sdk is a windows application, not a 
cygwin application
export CLASSPATH=".;c:\cygwin\j2sdk1.4.2\lib"

$ echo $CLASSPATH
.;c:\cygwin\j2sdk1.4.2\lib

3. cd <basedir>
   run configure as
./configure --prefix=<basedir>
with base dir in windows format

$ ./configure --prefix=/redo/antlr-2.7.2
...
configure: creating ./config.stat
cconfigure: creating ./config.status
config.status: creating scripts/Config.make
config.status: creating scripts/antlr-config
config.status: creating scripts/run-antlr
$


4. cd scripts & edit the Config.make just created to put the correct 
class path in
# Programs we might use and their options...
# next line commented
#ANTLR    = $(JAVA) -cp $(TOPDIR)/antlrall.jar antlr.Tool
ANTLR    = $(JAVA) -cp "C:\cygwin\redo\antlr-2.7.2" antlr.Tool


5. clear $CLASSPATH (not set it to blank, that does NOT work)
unset CLASSPATH

6. build with NO Classpath
make

$ make
=============================
Making dependencies...
=============================
make[1]: Entering directory `/redo/antlr-2.7.2/antlr'
...
===========================================
Making antlr.jar...
===========================================
===========================================
Making antlr.debug.jar...
===========================================
Building antlr/ANTLRTokdefLexer.java
Building antlr/ANTLRTokdefParser.java
Note: antlr/ANTLRTokdefParser.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
Building antlr/actions/cpp/ActionLexer.java
Building antlr/actions/java/ActionLexer.java
Building antlr/preprocessor/Preprocessor.java
Note: antlr/preprocessor/Preprocessor.java uses or overrides a 
deprecated API.
Note: Recompile with -deprecation for details.
Building antlr/preprocessor/PreprocessorLexer.java
===========================================
Making antlrall.jar...
===========================================

7. Make install with NO Classpath
make install

$ make install
Installing jar files into /redo/antlr-2.7.2/share/antlr-2.7.2
...
Installing config.hpp into /redo/antlr-2.7.2/include/antlr
make[3]: Leaving directory `/redo/antlr-2.7.2/lib/cpp/antlr'
make[2]: Leaving directory `/redo/antlr-2.7.2/lib/cpp'
make[1]: Leaving directory `/redo/antlr-2.7.2/lib'

8. check in antlr-2.7.2/lib for libantlr.a

9. set up class path to run
$ export 
CLASSPATH=".;c\cygwin\j2sdk1.4.2\lib;C:\cygwin\redo\antlr-2.7.2\antlrall.jar" 


10. create test directory
$ mkdir grammars
$ cp examples/cpp/*/*.g grammars
$ cd grammars

11. test
$antlr calc.g

Check for the hpp & cpp files in grammars


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20031125/93c261d0/attachment.html


More information about the antlr-interest mailing list