[antlr-interest] Using ANTLR on MSV .NET 2k3

Ric Klaren ric.klaren at gmail.com
Wed Nov 22 01:11:19 PST 2006


Hi,

On 11/22/06, Randolph Tan <ren_c_tan at yahoo.com> wrote:
> Then, I added all .cpp and .hpp files under antlr-2.7.6\lib\cpp\antlr and
> antlr-2.7.6\lib\cpp\src to the project.

The simplest to get to work is the static library version. Be sure to
exclude dll.cpp from the project then. (Not sure if it will be a
problem when not building a DLL, I'm no MSVC expert)

> I modified the sample grammar of the "cut and paste" tutorial from the ANTLR
> getting started to output C++. I also created a main function (translated
> Java example to C++).
>
> As I try to build the project, I got these errors:
> fatal error C1010: unexpected end of file while looking for precompiled
> header directive L.cpp

No clue about these. Probably MSVC needs some new syntactic sugar for
precompiled headers.

> I don't really understood what that meant but after I set both all cpp files
> to "not using precomiled headers", the project was able to compile
> succesfully.

Good.

> Then the build failed at linking with 20 errors and 19 warnings.
> One sample error (all of the errors are similar, just different symbols or
> different object files):
> CharScanner.obj : error LNK2005: "private: static int const
> antlr::CharScanner::NO_CHAR" (?NO_CHAR at CharScanner@antlr@@0HB) already
> defined in ANTLR test.obj

Or some objects are included twice or maybe you're using different
compile settings for the library and the project linking to it? Does
it work if you just make one big project with the antlr files and the
files from the sample?

I'm not sure which MSVC version you're exactly using if it's newer
then version 7.1 it may need some tweaking in the config.hpp. Looking
at the error you might have to tinker with the define that tells how
constants should be declared.

> Btw, if there is a link to a tutorial using ANTLR on MVS .NET. Please tell
> me! Thanks!

There have been some posts in the past to the mailing list. But these
have been mostly merged into the readme of the runtime (in lib/cpp)
When I get some time, or when someone else feels like it, it would be
nice to add a wiki page on it.

> PS. I am just curious, why does everybody want to build ANTLR into a
> library? If it can be built, why doesn't antler.org add it in its downloads
> section?

It seems Wolfgang didn't have time to make nice release packages for
the last version at least he did for 2.7.6 (or was it 2.7.5?).
Although with the C++ version one often has to recompile anyway for
specific compiler settings etc. Myself I never figured out how to make
a complete package with everything in it for windows. So usually if no
one contributes binaries they won't get made.

Cheers,

Ric


More information about the antlr-interest mailing list