[antlr-interest] Problem linking C++ generated parser

Ric Klaren ric.klaren at gmail.com
Sun Sep 4 16:32:59 PDT 2005


John Williams wrote:
> I have a requirement to build a parser in both Java and C++ under
> Windows and Linux and Antlr 2.7.5 seems to be the answer. My first
> attempts have been in Windows 2000, the generated Java is fine. My
> problem is the generated C++ source files. Compilation is fine but
> linking is the problem. I have tried cygwin, mingw and Visual C++ (V6)
> but all cases I am encountering linker problems. It was suggested by
> Sohail Somani in replying to my first post that I include the errors.
> 
> Below are the commands I used with cygwin in attempting to compile/link
> the C++ generated by antlr. The source grammar was the "calc" example
> supplied with antlr.
> 
> antlr calc.g
> g++ -c *.cpp
> g++ -o calc.exe Main.o CalcLexer.o CalcParser.o CalcTreeWalker.o -lantlr
> -lstdc++

Make sure to build the libantlr.a and the examples with the same version
of g++, due to abi changes incompatabilities may arise. The -lstdc++
should not be necessary on a correctly installed gcc.

What version of Cygwin are you using? What steps did you do to install
antlr?

Cheers,

Ric


More information about the antlr-interest mailing list