[antlr-interest] Antlr DLL

Thomas Dudziak tomdz at cs.tu-berlin.de
Fri Apr 26 15:17:16 PDT 2002


I've attached a patch for the C++ version of Antlr (more specifically Ric's
development version from march, 22.) which allows to compile it as a dll
(using STLPort). In addition, I've created a STLPort-specific VisualStudio6
workspace which allows to compile debug and release, static and dynamic
Antlr libraries. In order to test the libraries, there is an additional
workspace for the Antlr examples.

For those eager to test it, here are the instructions:

1. Install Antlr

Download and unpack the devel version of Antlr (antlr-devel-20020322.tar.gz
at http://wwwhome.cs.utwente.nl/~klaren/antlr/). You will get a directory
structure with one top-level directory "main".
Since the patch is a unified patch, it is possible that versions 2.7.2a1 or
a2 will also work.

2. Patch Antlr

Apply the patch in the directory containing main using the following command
(unix/cygwin)
    patch -p 1 -i antlr.patch
(Perhaps there is a windows or java version of the patch tool other than
that of cygwin ?).
Alternatively you also could try to apply the changes manually since the
format of the diff is relatively easy.

3. Install workspaces

Unzip the Antlrlib workspace to "<where you unpacked Antlr>/main/lib/cpp/".
Unzip the Examples workspace to "<where you unpacked Antlr>/main/examples/"

4. Install STLPort

Download (http://www.stlport.org/download.html) and compile STLPort (I've
used version 4.5.1)

Copy the following STLPort files from "<where you installed STLPort>/lib/"
to the directory "<where you unpacked Antlr>/main/lib/" :
    stlport_vc6_static.lib
    stlport_vc6.exp
    stlport_vc6.lib
    stlport_vc645.dll
The first one is for linking STLPort statically (e.g. creating a static
Antlr lib), the other three for creating an Antlr dll. Note that these are
all release libraries. The debug version of STLPort contains an ASSERT which
always fails when using STLPort with Antlr, but I did not have the time to
check it yet.
Alternatively, you can add the STLPort library directory ("<where you
installed STLPort>/lib/") to library directories used in the projects in the
Antlrlib and Examples workspaces.

5. Set STLPort as the STL implementation that Visual Studio uses

Change the STL used by Visual Studio for the Antlrlib workspace by adding
the "<where you installed STLPort>/stlport/" directory in
Tools->Options->Directories ("Show directories for include files") and
moving it up to the first place. This is an important step as otherwise
Visual Studio will always use its own STL implementation regardless as to
whether you added the above directory to a project's include directories or
not. However this will change the STL for all workspaces, not only for the
current one (but it is probably a good idea anyway as STLPort is certainly
superior to the Visual Studio 6 STL implementation).

6. Build Antlr libraries

Do a batch build of all Antlr library/dll projects in the Antlr workspace.
The resulting four libraries (antlr.lib, antlrD.lib, antlrdll.lib,
antlrdllD.lib) and two dlls (antlrdll.dll, andlrdllD.dll) are placed in
"<where you unpacked Antlr>/main/lib/".


Thats it for the libraries. For generating static libraries that use the
Visual Studio STL implementation, simply use the original Antlr workspace
(part of the distribution) before changing the Visual Studio include
directories (e.g. after Step 2 but before Step 5).

To use the libraries, you have to do the following:
- static library with Visual Studio STL implemenation:
    No specific steps necessary.
- static library with STLPort STL implementation:
    Define the ANTLR_STLPORT macro in the C++ tab of the project properties.
    Link against antlr.lib (release) or antlrD.lib (debug).
- dll
    Define the ANTLR_IMPORTS macro in the C++ tab of the project properties.
    Link against antlrdll.lib (release) or antlrdllD.lib (debug).

The projects in the Examples workspace each define the four configurations
for linking against debug or relase and static or dynamic Antlr library.
However, two examples won't work. In the FlexLexer example, the generated
code won't compile (seems to be a problem with Antlr itself). The Java
example crashes in a STL part (access violation), and it does so both in
static and dynamic STLPort builds (needs further investigation).

Note that the workspaces won't work for Visual Studio 5 (no backwards
compatibility) nor for Visual Studio.NET. The latter has a new, much
improved STL implementation which might be better suited for DLL creation,
but I could not check this yet as I do not currently use VS.NET. This also
means that I could not verify that the workspaces/steps work in VS.NET.

Ciao, Tom


 

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: antlr-dll-patch.zip
Type: application/x-zip-compressed
Size: 45761 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20020427/9de30bd6/antlr-dll-patch.bin


More information about the antlr-interest mailing list