By submitting your information, you agree that jguru.com may send you jGuru offers via email, phone and text message, as well as email offers about other products and services that jGuru believes may be of interest to you. jGuru will process your information in accordance with the Quinstreet Privacy Policy.

Where can I download Microsoft VC project file to build CPP LIB for ANTLR?

Check in the distribution (2.7.1 and beyond) for antlr/lib/cpp/contrib/*. You will see MSCV6 project files.

Explanation:

Some caveats:

This is for Visual C++ 6.0. Use At Your Own Risk for other
versions. (I think 4.0 doesn't have all the C++ language elements
you need for Ric's code, so do yerselves a favor and score a copy of
6.)

The files that I mention in there can be found in the Files section
of this list's website (http://groups.yahoo.com/group/antlr-
interest). There you will find a zip file called "antlr_calc.zip".
The full URL to that file is http://groups.yahoo.com/group/antlr-
interest/files/antlr_calc.zip.

Using my libantlr project files, be warned that the debug version
of the ANTLR lib weighs in at a whopping 2.8MB!

And on with the show...

First of all, put libantlr.dsw and libantlr.dsp into your
antlr-2.7.1libcpp directory. Open up libantlr.dsw,
and then do a Batch Build from the Build menu to build
both the Debug and Release versions.

These project files output .lib files (not DLL's!), so
they must be statically linked in the calc project.
(We'll get there in a minute.) The debug version of
the ANTLR library ends up as
antlr-2.7.1libcpplibantrld.lib, and the release
version ends up as libcpplibantlr.lib.

When you compile the ANTLR library, you will likely
get 4 warnings. Ignore them--it'll work okay.

Now for the calc project!

Start by creating a new workspace project for a Win32
console program called calc. Make sure it's saved to
the antlr-2.7.1examplescppcalc directory.

Add both the Main.cpp and calc.g files to the new
project. VC++ won't have a clue how to handle calc.g
yet.

First, let's add the ANTLR library to the project. Go
the Project Settings (Project menu), click on the calc
project at the top of the tree, and make sure it says
"Win32 Debug". Now click on the Link tab, and in the
Object/library modules box, add
"antlr-2.7.1libcpplibantlrd.lib" (without the
quotes) to the beginning. Now change the Settings For
drop-down to "Win32 Release", and add
"antlr-2.7.1libcpplibantlr.lib" to the same box.
You've just added the ANTLR library to the project.

Leave that window open, because now we have to tell
the project where the include files are for ANTLR!

Click on the "calc" entry at the top of the project
tree in the Project Settings window, and then select
"All Configurations" under the Settings For dropdown
on the left. Then click on the C/C++ tab. Select
"Preprocessor" under the Category dropdown.

Now, under "Additional include directories", add
"antlr-2.7.1libcpp" without the quotes. Now click
OK.

Getting the .g files to compile without any problems
when you do a build is a tricky one, but it can be
done.

First, right-click on the calc.g file in the project
view, and click Settings. Now select "All
Configurations" from the Settings For drop-down on the
project window. Now click on the Custom Build tab.

Type something in for the description, like
"Performing Custom Build Step on $(InputPath)".

Under Commands, type:
java antlr.Tool -o $(InputDir) $(InputPath)

Under Outputs, you have to put in the name of every
file that ANTLR will generate from the .g file! So,
for the calc project, the list will be:

Now right-click on calc.g in the Project view, and
select "Compile calc.g". You should get a message
that it's compiling, and then get zero errors.

Now all those .cpp and .hpp files are there! So add
them to the project! Click on the Project menu, "Add
to Project", then "Files", and select all the .cpp and
.hpp files. (You'll have to change the "Files of
type" dropdown to "All Files" to see the .hpp files.)

And after all that work, you're all done! Doing a
Rebuild All will cause everything to be recompiled,
including calc.g.

After all that, you'll probably think strongly about
just doing it all on Unix using make! :-) I usually
work in Cygwin now, just so I can use make on Windows
ANTLR projects.