[antlr-interest] Unresolved externals building C executable

Jim Idle jimi at temporal-wave.com
Fri Jul 11 11:37:33 PDT 2008


On Fri, 2008-07-11 at 18:35 +0100, Artemus Ward wrote:

> 2008/7/11 Jim Idle <jimi at temporal-wave.com>:
> > On Fri, 2008-07-11 at 22:08 +1200, Gavin Lambert wrote:
> >
> > At 21:37 11/07/2008, Artemus Ward wrote:
> >  >If I don't use /NODEFAULTLIB:MSVCRT then I get these errors
> >  >instead:
> > [...]
> >  >MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined
> > in
> >  >LIBCMT.lib(free.obj)
> >  >MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined
> >
> >  >in LIBCMT.lib(calloc.obj)
> >
> > Which means that you've probably set the ANTLR library to use the
> > CRT DLL and the application to use the CRT statically.  They must
> > agree with each other exactly if you're going to statically link
> > them.
> >
> > There really is not any reason to use the static versions of the libraries -
> > you should abandon your current MS project and create a new one. This time
> > don't change the default settings until you know what they all mean.
> 
> I didn't start changing them off until the MS compiler and linker
> started displaying messages suggesting that was the thing to do.
> Clearly one could spend a long time reading the copious documentation,
> but one could also seek the advice of those who've done it already.
> 
> I shall do as you suggest, although that means I now have to go back
> and figure out why I was able to compile the static libraries
> successfully but the DLL is somehow corrupt.  I didn't knowingly mess
> with any flags when I built it.


It is unfortunately, all too easy to do. If you don't want to start
again with the project, then the easiest thing to do is to start two VS
sessions, one with your project, one with the C demo solution (which I
put together so that  people had a start point, for exactly this reason
- Visual Studio 2008 is by far the best C IDE I have ever used, but the
project config takes a bit of leanring, though I suppose so does
autoconf and gmake ;-). Go through the General settings and the C/C++
and Linker settings and make sure you have the library configurations
set the same way as the demo projects do. That should fix it all up for
you. Any minute now you will be saying "AhhhhhhH!" and not
"Arrrrrgh!" :-)

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080711/ef097568/attachment.html 


More information about the antlr-interest mailing list