[antlr-interest] Antlr-2.7.6 with Visual Studio 8.0

Mark Kattenbelt mark.kattenbelt at gmail.com
Thu Mar 16 05:19:05 PST 2006


Hi,

Forget about my previous email. The errors have been caused by my own 
stupidity. It always seems as though as soon as you decide to ask for 
help you find the cause of the problem yourself.

For future reference: The problem was that I made antlr into a dynamic 
library, and my project linked to this dll. I compiled both against the 
multi threaded debug runtime library (staticly linked), whereas I should 
have been compiling against the multi-threaded debug DLL runtime library 
(dynamicly linked). My guess is that if both the dll and the exe have 
their own staticly linked runtime library that there arise problems with 
memory allocation and deallocation on the heap, whereas a shared 
dynamicly linked library does not have this problem.

I suppose this is an obvious mistake, however I missed it.

I can start making a promela grammar now!

Mark
> Mark,
>
> If it is any help, I built a static library (.lib) using 2.7.6 with 
> the command line.
>
> /Od /I "C:\Development\antlr\antlr-2.7.6\lib\cpp\\" /D "WIN32" /D 
> "_DEBUG" /D "_LIB" /D "_CRT_SECURE_NO_DEPRECATE" /D 
> "_VC80_UPGRADE=0x0600" /D "_MBCS" /FD /EHsc /RTC1 /MDd /Zc:wchar_t- 
> /Zc:forScope- /GR- /Fp".\Debug/antlr_lib.pch" /Fo".\Debug/" 
> /Fd".\Debug/" /FR".\Debug\\" /W3 /nologo /c /Z7 /errorReport:prompt
>
> There is a change in TokenStreamRewriteEngine.cpp (already submitted 
> to Ter)
>
> #ifndef NO_STATIC_CONSTS
> const size_t TokenStreamRewriteEngine::MIN_TOKEN_INDEX = 0;
> const int TokenStreamRewriteEngine::PROGRAM_INIT_SIZE = 100;
> #endif
>
>
> At 10:40 14/03/2006, Mark Kattenbelt wrote:
>> Hello,
>>
>> I've been trying to compile a dll of antlr 2.7.6 in Visual Studio 
>> 2005, so far unsuccessfully.
>> In mingw, I manage to compile it fine, only took a few minutes to set 
>> up! I use the following settings for VS:
>>
>> Include dir: "lib\cpp"
>> Preprocessor: WIN32;_DEBUG;_WINDOWS;_USRDLL;ANTLR_EXPORTS
>> Run-time library: Multi-treaded debug.
>> Create precompiled headers: yes.
>> Function level linking: yes.
>> RTTI: yes.
>>
>> Which results into compiling with the following line:
>>
>> /O2 /I "lib\cpp" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D 
>> "ANTLR_EXPORTS" /D "_WINDLL" /FD /EHsc /MTd /Gy /Yc 
>> /Fp"Debug\antlr-2.7.6.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /nologo 
>> /c /TP /errorReport:prompt
>>
>> And linking with:
>>
>> /OUT:"d:\Fmt\antlr-2.7.6\Debug\antlr-2.7.6.dll" /NOLOGO /DLL 
>> /MANIFEST /MANIFESTFILE:"Debug\antlr-2.7.6.dll.intermediate.manifest" 
>> /ASSEMBLYDEBUG /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib 
>> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
>> oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
>>
>> Now this fails during the linking stage, in particular it keeps 
>> finding symbols that are defined in multiple places:
>>
>> ASTFactory.obj : error LNK2005: "class std::basic_istream<char,struct 
>> std::char_traits<char> > & __cdecl antlr::eatwhite(class 
>> std::basic_istream<char,struct std::char_traits<char> > &)" 
>> (?eatwhite at antlr@@YAAAV?$basic_istream at DU?$char_traits at D@std@@@std@@AAV23@@Z) 
>> already defined in ANTLRUtil.obj
>> ASTFactory.obj : error LNK2005: "class std::basic_string<char,struct 
>> std::char_traits<char>,class std::allocator<char> > __cdecl 
>> antlr::read_string(class std::basic_istream<char,struct 
>> std::char_traits<char> > &)" ...
>>
>> I have tried to compile without precompiled headers, because I do not 
>> see the need for them, this results in:
>>
>> MismatchedCharException.obj : error LNK2005: "public: static int 
>> const antlr::MismatchedCharException::CHAR" 
>> (?CHAR at MismatchedCharException@antlr@@2HB) already defined in 
>> CharScanner.obj
>> MismatchedCharException.obj : error LNK2005: "public: static int 
>> const antlr::MismatchedCharException::NOT_CHAR" 
>> (?NOT_CHAR at MismatchedCharException@antlr@@2HB) already defined in 
>> CharScanner.obj
>> MismatchedCharException.obj : error LNK2005: "public: static int 
>> const antlr::MismatchedCharException::RANGE" 
>> (?RANGE at MismatchedCharException@antlr@@2HB) already defined in 
>> CharScanner.obj
>>
>> Clearly I am doing something wrong, and the settings need tweaking. 
>> Has anyone here managed to build antlr (2.7.6?) with Visual Studio 
>> (8.0?). If so could you please share your settings? Any help is 
>> appreciated.
>>
>> Also, trying to compile it into a static library does not offer any 
>> relief, the errors still persist.
>>
>> Cheers,
>>
>> Mark Kattenbelt
>>
>>
>>
>
>
> Regards
>
> Mike
>
>
> Mike Ventham
> Chief Technical Consultant
> Double V Design & Support Services
> Email : mike at doublevdesign.co.uk
>
>
>



More information about the antlr-interest mailing list