ANTLR4.10.1 C++ target doesn't compile with CMake/MSVC2019/2022 32-Bit anymore (and more problems with C++ Target)

394 views
Skip to first unread message

Johann Anhofer

unread,
Apr 21, 2022, 4:05:35 AM4/21/22
to antlr-discussion
1.) Building with CMake: 32-Bit Builds fail with 67 Linker errors: 
LNK2001    unresolved external symbol "public: static unsigned int __cdecl antlr4::misc::MurmurHash::update(unsigned int,void const *,unsigned int)" (?update@MurmurHash@misc@antlr4@@SAIIPBXI@Z)    runtime\XPathWildcardAnywhereElement.cpp.obj 
its always the same error on different files.

2.) Building with Visual Studio (Project Files)
Fails for all Plattforms with Files not found 

3.) Building with MsBuild (deploy-windows.cmd)
Fails for all Plattforms with Files not found 
e.g.
"c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj" (Standardziel) (1) ->
(ClCompile Ziel) ->
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\AbstractPredicateTransition.cpp': No such file or directo
ry [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\ATNSerializer.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\BasicBlockStartState.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\BasicState.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\BlockEndState.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\BlockStartState.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]
  c1xx : fatal error C1083: Cannot open source file: 'src\atn\EmptyPredictionContext.cpp': No such file or directory [ c:\source\antlr4\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj]

Michal Widera

unread,
Apr 21, 2022, 3:52:24 PM4/21/22
to antlr-di...@googlegroups.com
Hi Johann,

First of all - please consider usage of build automation tools for C++.
In the Java environment there are two eras - b.m and a.m - Before
Maven and After Maven.
In C++ we have Conan - something rather new - but Conan is what Maven
for Java is.
Antlr 4.10.1 compiles correctly for C++ MSVC 16 / 64 bit version correctly.
Project runs and parser works - here is a living example
https://github.com/michalwidera/Antlr4ConanExample
You will find some issues with MSVC on the 4.10 version.
In case of 32 bit version - just use --build missing for conan build
command if you want to build 32 bit version.
You can check what versions are compiled and tested here:
https://conan.io/center/antlr4-cppruntime

Looking in your post I think that you have linked in your project
files that came from 4.9.3 - AbstractPredicateTransition.cpp - etc.
They do not exist in runtime anymore.
Moreover you need to recompile your grammar with the 4.10.1 grammar compiler.
The Major number of versions (9->10) has changed and there are no bug
fixes but output of generated results can be different.
Input (.g4 file) remains the same - or it is backward compatible but
output could change.
Output in Antlr4 for C++ is a set of .cpp files and runtime.
You shouldn't link directly your project with inner runtime libraries
- compile it separately or use binaries from conan. As you wish.

That's mine advice,

Regards,
M.
> --
> You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/26645160-610b-4275-9d21-2bd434915494n%40googlegroups.com.

Michal Widera

unread,
Apr 21, 2022, 4:05:59 PM4/21/22
to antlr-di...@googlegroups.com
I've found reference to these missing files in antlr4cpp-*.vcxproj files.
It looks like these files contain broken references to non-existent
files from 4.9.3
Try using CMake to build these sources or regenerate vcxproj files.
CMake works correctly here.
https://stackoverflow.com/questions/57114825/convert-cmake-txt-to-vcxproj-file-c-visual-studio-project

Terence Parr

unread,
Apr 21, 2022, 7:40:34 PM4/21/22
to antlr-discussion
I don't know how to build those project files. If someone can build those files and give them to me, I can upload them to the website.
Ter



--
Dictation in use. Please excuse homophones, malapropisms, and nonsense.

Johann Anhofer

unread,
Apr 22, 2022, 2:00:25 AM4/22/22
to antlr-discussion
Generating the project as stated in the Stackoverflow article for Platform Win32 and compile it with VS 2019 bring the same linker errors and much more.
cmake -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_GENERATOR_PLATFORM=Win32 -G "Visual Studio 16 2019" e:\projects\github\antlr4\runtime\Cpp

The project was freshly checked out from the github repository.

Compiling with cmake 
cmake -DCMAKE_BUILD_TYPE=Release -G Ninja e:\projects\github\antlr4\runtime\Cpp -DWITH_STATIC_CRT=OFF -DANTLR_BUILD_CPP_TESTS=OFF -DWITH_DEMO=OFF
cmake --build . 
in MSVC 2019/64 Environment builds correctly.
Doing the same in a MSVC 2019/32 Environment shows the above linker errors.
This was not the case before ANTLR 4.10, 4.9.3 builds for both platforms.

Regards, Johann

Mike Lischke

unread,
Apr 22, 2022, 2:33:39 AM4/22/22
to 'rtm...@googlemail.com' via antlr-discussion
The project was freshly checked out from the github repository.

Compiling with cmake 
cmake -DCMAKE_BUILD_TYPE=Release -G Ninja e:\projects\github\antlr4\runtime\Cpp -DWITH_STATIC_CRT=OFF -DANTLR_BUILD_CPP_TESTS=OFF -DWITH_DEMO=OFF
cmake --build . 
in MSVC 2019/64 Environment builds correctly.
Doing the same in a MSVC 2019/32 Environment shows the above linker errors.
This was not the case before ANTLR 4.10, 4.9.3 builds for both platforms.

Best is to open a bug report against the C++ target on Github and someone from the C++ guys will take a look.


Reply all
Reply to author
Forward
Message has been deleted
0 new messages