[antlr-interest] Re: More VC++ 6 Confusion (MFC libs)

kemmerzehl malitrait at start.com.au
Tue Jan 1 10:02:10 PST 2002


The problem I had was actually incredibly simple, and I do feel a 
little silly now. The project files JSRS posted were using the single 
thread runtime libraries to build the antlr lib, and this was fine 
for projects NOT using MFC because by default they are also use the 
single thread runtime libraries. When I create a project with MFC 
support, however, it switches to using the multi thread runtime 
libraries. Trying to link these with the single threaded antlr 
library was causing all sorts of compatibility problems. Building 
another set of the antlr libs using the /MT and /MTd (instead of /ML 
and /MLd) flags to link with projects using the multithreaded runtime 
libraries solved the problem.
Simple.
..and luckily i didnt rip ALL of my hair out.

Thanks for your input and I apoligise for confusing you all with such 
a simple issue.
-Kemmerzehl

--- In antlr-interest at y..., "kemmerzehl" <malitrait at s...> wrote:
> Hi,
>   I do hate to add to your list of confused VC++ user messages but 
> I've followed the steps from your existing discussions/literature 
and 
> I'm still having some problems. It appears this particular issue 
has 
> not yet been addressed although it seems like it would be a 
> common problem so I do apologise if I've missed something.
>   Anyway, here's the problem. Quite simply, the ANTLR and MFC libs 
> just wont work for me together - I get link errors. I've built my 
> ANTLR lib files according to JSRS's 'How To', and by themselves 
they 
> work well. If I use VC++ to create a 'Win32 Console Application' 
and 
> do NOT include MFC support, then add the generated calc example 
files 
> and add the ANTLR library, everything compiles links and runs fine. 
> If, however, I do the same thing only I DO include MFC support (and 
> remembering to take off the /Yu"stdafx.h" flag), I get the 
following 
> link errors:
> 
> LIBC.lib(cfout.obj) : error LNK2005: ___dtold already defined in 
> libcmt.lib(cfout.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __cinit already defined in 
> libcmt.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in 
> libcmt.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in 
> libcmt.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __cexit already defined in 
> libcmt.lib(crt0dat.obj)
> ..etc.
> 
>   One rather odd thing is that I can get the _debug_ build to work
> (for the calc example) if I link statically to MFC and use the /MT 
> flag instead of /MTd(default for debug builds). These flags 
represent 
> the "Multithreaded" and "Debug Multithreaded" runtime libraries, 
> available in the "Code Generation" dropdown section of the "C++" 
tab 
> in Project -> Settings. This however does not fix the problem for 
the 
> release build, I even tried using JSRS's debug version of the ANTLR 
> library with the release build (using /MT) and I still got link 
> errors. Also, I could not get rid of the link errors at all for the 
> project im working on (with either build).
>   All of this is purely trial and error for me as I've never had to 
> deal with third-party libraries before. I hope some of the info 
I've 
> provided can be of use and that somebody out there has experienced 
> this linking problem before and knows how to fix it. Either way, 
I'm 
> going to keep ripping my hair out trying to fix it, if I find a 
> solution I'll post it.
> 
> Thanks,
> -Kemmerzehl


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list