[antlr-interest] Unresolved externals building C executable

Artemus Ward coddbotherer at googlemail.com
Fri Jul 11 02:37:48 PDT 2008


2008/7/11 Gavin Lambert <antlr at mirality.co.nz>:
> At 19:56 11/07/2008, Artemus Ward wrote:
>>I spent much of yesterday afternoon teasing out the C examples;
>>hassling with MS Visual Studio registration; building the ANTLR
>>libraries for my target machine, and just generally rediscovering
>>why I had started out using Java for this project--but I digress.
>>
>>I'm getting a load of missing externals when I try to link my
>>little "hello antlr" program:
> [...]
>>/NODEFAULTLIB:MSVCRT
> [...]
>>C:\antlr-3.0.1\runtime\C\Release\antlr3c.lib
>>   Creating library GrantLexer.lib and object GrantLexer.exp
>>Test.obj : error LNK2001: unresolved external symbol
>>_ANTLR3_FPRINTF
>>antlr3c.lib(antlr3lexer.obj) : error LNK2001: unresolved external
>>symbol __imp__fprintf
>>antlr3c.lib(antlr3filestream.obj) : error LNK2001: unresolved
>>external
>
> Well, it looks like you've compiled the ANTLR library with settings
> expecting the CRT to be loaded as a DLL, and then refused to link your
> application against the CRT import library.

If I don't use /NODEFAULTLIB:MSVCRT then I get these errors instead:

Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:GrantLexer.exe
/LTCG
GrantLexer.obj
GrantParser.obj
Test.obj
C:\antlr-3.0.1\runtime\C\Release\antlr3c.lib
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)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: ___iob_func already defined
in LIBCMT.lib(_file.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isprint already defined in
LIBCMT.lib(_ctype.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove already defined in
LIBCMT.lib(memmove.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in
LIBCMT.lib(fclose.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc already defined in
LIBCMT.lib(realloc.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in
LIBCMT.lib(atox.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isdigit already defined in
LIBCMT.lib(_ctype.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strdup already defined in
LIBCMT.lib(strdup.obj)
   Creating library GrantLexer.lib and object GrantLexer.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of
other libs; use /NODEFAULTLIB:library
Test.obj : error LNK2001: unresolved external symbol _ANTLR3_FPRINTF
GrantLexer.exe : fatal error LNK1120: 1 unresolved externals

Art


More information about the antlr-interest mailing list