Unable to compile C++ runtime for antlr 4.10 and 4.10.1

256 views
Skip to first unread message

Torsten Fichtner

unread,
Apr 16, 2022, 10:39:25 PM4/16/22
to antlr-discussion
When I compile the antlr4cpp project I get a number of errors like "Cannot open source file: 'src\atn\BasicState.cpp': No such file or directory". The full list is attached.

Some source files seem to be missing in the atn, support, and tree folders of the solution to build the antlr runtime for the c++ target.

Torsten
error.txt

Terence Parr

unread,
Apr 17, 2022, 4:29:49 PM4/17/22
to antlr-di...@googlegroups.com
Hi, I don't see that file anywhere in the source code:

Error C1083 Cannot open source file: 'src\atn\AbstractPredicateTransition.cpp': No such file or directory antlr4cpp-vs2019 D:\antlr\antlr-4.10\antlr4-cpp-runtime-4.10\runtime\c1xx 1

It looks like the vs2019 thing what does not update it but I don't know how to update it…

Ter

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


--
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/c7ce449a-2f89-48fb-bc6d-ec079dbf96ben%40googlegroups.com.

Peter Boulton

unread,
Aug 30, 2022, 2:42:44 PM8/30/22
to antlr-discussion
Hi Terence,

I too am getting the same issue as Torsten.  I used the VS2022 IDE and removed all the source files listed in Torsten's list from the project, as you suggested in your reply to Torsten (well, the files that VS2022 showed me were missing via the displayed icon against each file).

The project then successfully compiles, albeit with lots of warnings ( e.g. "Warning    C4275    non dll-interface class 'std::exception' used as base for dll-interface class 'antlr4::RuntimeException' (compiling source file src\ANTLRErrorListener.cpp)    antlr4cpp-vs2019    E:\Downloads\Antlr\DeploymentManual\Cpp\runtime\src\Exceptions.h    13).

However, I then get 85 LNK2019 errors(unresolved external symbol), such as "Error    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)    antlr4cpp-vs2019    E:\Downloads\Antlr\DeploymentManual\Cpp\runtime\XPathTokenAnywhereElement.obj    1")

I was hoping to use Antlr for a project but it's a bit of a struggle just getting out of the starting gates in C++!

Pete

Terence Parr

unread,
Aug 30, 2022, 3:20:25 PM8/30/22
to antlr-discussion
Sorry to hear that Pete. Yes I'm also having a bit of trouble; C++ is nowhere near the portability win it claims to be haha.  I did manage to get it to work on mac silicon, but I've not tried it for Windows stuff. Perhaps some of the Microsoft experts here could help us out and we can update the IDE project files?

Ter



--

ivan.ko...@gmail.com

unread,
Aug 31, 2022, 3:33:42 PM8/31/22
to antlr-discussion
C++ runtime Windows configuration should definitely work. We have passing tests: https://github.com/antlr/antlr4/runs/8063326573?check_suite_focus=true

What branch have you tried? Please try dev if you tried master.

вторник, 30 августа 2022 г. в 21:20:25 UTC+2, Terence Parr:

Terence Parr

unread,
Aug 31, 2022, 4:46:57 PM8/31/22
to antlr-discussion
Also note that we are hoping to go out with 4.11 sometime over the weekend or at least a release candidate.

Peter Boulton

unread,
Sep 1, 2022, 5:56:08 AM9/1/22
to antlr-discussion
Hi,

Thanks for taking the time to respond.  I was using the download https://codeload.github.com/antlr/antlr4/zip/refs/heads/master and the Visual Studio solution file "antlr4-master\runtime\Cpp\runtime\antlr4cpp-vs2019.vcxproj" from the downloaded zip to build the dll using the VS2022 IDE.

When VS2022 opens the project file it upgrades the project to the latest Windows SDK version (10.0) and Platform Toolset (v143).  After a lot of perseverance and diagnosis I discovered that a number of source files were included in the solution which are no longer included in the source code zip (no icon in Solution Explorer) so I removed them from the project.

I then discovered that a number of source files in the zip master were NOT included in the VS project file and added them.  Specifically:

src\atn\PredictionContextCache.cpp
src\atn\PredictionContextMergeCache.cpp
src\misc\MurmurHash.cpp
src\support\Utf8.cpp
src\atn\PredictionContextCache.h
src\atn\PredictionContextMergeCache.h
src\support\Utf8.h

When I added them and compiled/linked the build ran successfully, albeit with a number of warnings.

I've attached my corrected version of the project file.  It will work without adjustment on the current version of VS2022.  On VS2019 or non-latest VS2022 you will need to correct the Windows SDK version and Platform Toolset versions in the build settings property pages.

You can use a differ to compare my version of the project file with the one in the downloaded zip to see what was removed / added to make to build successfully.

So, in theory, I should be 'all systems go'.  However, I am now finding that the C++ code generated by antlr-4.10.1-complete.jar for the TSQL grammar files from https://github.com/teverett/grammars-v4/tree/master/sql/tsql do not compile for me in VS2022, with hundreds of errors, which look syntactical.  Specifically:

Code    Description    Number of errors
====    ===========    ================
"C1003"    "error count exceeds 100; stopping compilation"    5
"C2039"    "'Constant_LOCAL_IDContext': is not a member of 'TSqlParser'"    355
"C2039"    "'Entity_name_for_azure_dwContext': is not a member of 'TSqlParser'"    355
"C2039"    "'Entity_name_for_parallel_dwContext': is not a member of 'TSqlParser'"    355
"C2039"    "'Entity_nameContext': is not a member of 'TSqlParser'"    355
"C2039"    "'Id_Context': is not a member of 'TSqlParser'"    355
"C2039"    "'Sql_clausesContext': is not a member of 'TSqlParser'"    355
"C2059"    "syntax error: ')'"    15
"C2059"    "syntax error: 'constant'"    15
"C2086"    "'int *input': redefinition"    5
"C2143"    "syntax error: missing ')' before '*'"    35
"C2143"    "syntax error: missing ';' before '&'"    35
"C2143"    "syntax error: missing ';' before '*'"    35
"C2143"    "syntax error: missing ';' before '}'"    35
"C2143"    "syntax error: missing '}' before 'constant'"    35
"C2178"    "'antlr4::TokenStream' cannot be declared with 'explicit' specifier"    5
"C2238"    "unexpected token(s) preceding ';'"    5
"C2259"    "'TSqlParser': cannot instantiate abstract class"    10
"C2270"    "'getATN': modifiers not allowed on nonmember functions"    25
"C2270"    "'getGrammarFileName': modifiers not allowed on nonmember functions"    25
"C2270"    "'getRuleNames': modifiers not allowed on nonmember functions"    25
"C2270"    "'getSerializedATN': modifiers not allowed on nonmember functions"    25
"C2270"    "'getVocabulary': modifiers not allowed on nonmember functions"    25
"C2280"    "'TSqlParser::TSqlParser(void)': attempting to reference a deleted function"    5
"C2530"    "'options': references must be initialized"    5
"C2575"    "'TSqlParser': only member functions and bases can be virtual"    5
"C2588"    "'::~TSqlParser': illegal global destructor"    5
"C3158"    "'getATN': 'override' can only be applied to a virtual member function"    30
"C3158"    "'getGrammarFileName': 'override' can only be applied to a virtual member function"    30
"C3158"    "'getRuleNames': 'override' can only be applied to a virtual member function"    30
"C3158"    "'getSerializedATN': 'override' can only be applied to a virtual member function"    30
"C3158"    "'getVocabulary': 'override' can only be applied to a virtual member function"    30
"C3158"    "'TSqlParser': 'override' can only be applied to a virtual member function"    30
"C4430"    "missing type specifier - int assumed. Note: C++ does not support default-int"    25
"E0020"    "identifier ""_ctx"" is undefined"    116
"E0020"    "identifier ""_input"" is undefined"    116
"E0020"    "identifier ""_localctx"" is undefined"    116
"E0020"    "identifier ""Begin_conversation_dialogContext"" is undefined"    116
"E0020"    "identifier ""Column_name_listContext"" is undefined"    116
"E0020"    "identifier ""CONCAT_WSContext"" is undefined"    116
"E0020"    "identifier ""End_conversationContext"" is undefined"    116
"E0020"    "identifier ""Entity_nameContext"" is undefined"    116
"E0020"    "identifier ""Exist_methodContext"" is undefined"    116
"E0020"    "identifier ""Expression_listContext"" is undefined"    116
"E0020"    "identifier ""File_specContext"" is undefined"    116
"E0020"    "identifier ""Full_column_nameContext"" is undefined"    116
"E0020"    "identifier ""Full_table_nameContext"" is undefined"    116
"E0020"    "identifier ""Func_proc_name_database_schemaContext"" is undefined"    116
"E0020"    "identifier ""Func_proc_name_schemaContext"" is undefined"    116
"E0020"    "identifier ""Func_proc_name_server_database_schemaContext"" is undefined"    116
"E0020"    "identifier ""Get_conversationContext"" is undefined"    116
"E0020"    "identifier ""getInterpreter"" is undefined"    116
"E0020"    "identifier ""Hierarchyid_callContext"" is undefined"    116
"E0020"    "identifier ""Modify_methodContext"" is undefined"    116
"E0020"    "identifier ""Nodes_methodContext"" is undefined"    116
"E0020"    "identifier ""Query_methodContext"" is undefined"    116
"E0020"    "identifier ""Send_conversationContext"" is undefined"    116
"E0020"    "identifier ""Simple_nameContext"" is undefined"    116
"E0020"    "identifier ""Table_nameContext"" is undefined"    116
"E0020"    "identifier ""TRIMContext"" is undefined"    116
"E0020"    "identifier ""Value_callContext"" is undefined"    116
"E0020"    "identifier ""Value_methodContext"" is undefined"    116
"E0029"    "expected an expression"    38
"E0040"    "expected an identifier"    9
"E0065"    "expected a ';'"    83
"E0077"    "this declaration has no storage class or type specifier"    287
"E0169"    "expected a declaration"    407
"E0254"    "type name is not allowed"    3
"E0260"    "explicit type is missing ('int' assumed)"    14


I am currently, very reluctantly, considering whether it's worth the time to continue further with Antlr.  It may indeed be that I am too stoopid to use it, but I have invested several days in trying to work through all this.  Antlr does look perfect for what I'm hoping to achieve.  Also, it was great that someone appears to have already done the heavy lifting on TSQL grammar files for Antlr, which is the specific language I'm hoping to work with.  

But.... the above looks to be a bit of a brick wall for me.  (I'm not 100% clear on this but am wondering whether the C++ that antlr-4.10.1-complete.jar generates from the language files is not compatible with Microsoft's version of C++ (though they do claim to be conformant among the various build options available)).

I'd be really happy if anyone can help get me over the line on this, though I realise it's asking a lot!

Sorry this post is so long, and I hope the attached VS2022 project file is of some help to anyone!

Pete
antlr4cpp-vs2019.vcxproj

Peter Boulton

unread,
Sep 5, 2022, 6:31:26 AM9/5/22
to antlr-discussion
The antlr4cpp-vs2022.vcxproj project file for V4.11.1 now compiles in VS2022 and produces the .dll and .lib files.

However  the C++ code generated by antlr-4.11.1-complete.jar for the TSQL grammar files from https://github.com/teverett/grammars-v4/tree/master/sql/tsql still do not compile for me in VS2022, with hundreds of errors, which look syntactical, similar to my previous post above (https://groups.google.com/g/antlr-discussion/c/_Zvou6rwTcY/m/BcliQxNxBwAJ).  Would welcome suggestions / clarifications on this as, for me at least, there are far too many compile errors for my small brain to correct!

Pete

Terence Parr

unread,
Sep 5, 2022, 12:58:46 PM9/5/22
to antlr-di...@googlegroups.com

On Sep 5, 2022, at 3:31 AM, Peter Boulton <peters...@gmail.com> wrote:

The antlr4cpp-vs2022.vcxproj project file for V4.11.1 now compiles in VS2022 and produces the .dll and .lib files.

Excellent.


However  the C++ code generated by antlr-4.11.1-complete.jar for the TSQL grammar files from https://github.com/teverett/grammars-v4/tree/master/sql/tsql still do not compile for me in VS2022, with hundreds of errors, which look syntactical, similar to my previous post above (https://groups.google.com/g/antlr-discussion/c/_Zvou6rwTcY/m/BcliQxNxBwAJ).  Would welcome suggestions / clarifications on this as, for me at least, there are far too many compile errors for my small brain to correct!

yes, I am shocked at the insane error messages generated by C++, but that's what happens when you have an insane/ugly language. I added a Single print statement yesterday and got hundreds of lines of error messages.  Somebody needs to have an intervention with the C++ folks and tell them to just stop and work on something else. It's bad enough as it is.


In short, I tried to help look at the C++ target but immediately ran into absurdities :(

Ter

Peter Boulton

unread,
Sep 5, 2022, 1:57:46 PM9/5/22
to antlr-discussion
Hi Ter,

I definitely feel your pain! :-(

It is certainly the case that a trivial coding typo or error on one line of a C++ project can generate hundreds of errors.  As a C++ developer, that's why I typically build frequently and can reverse out changes till I locate the issue that's stopping the compile.  I'd assumed this issue relates to C++ being a compiled language - or is it just that the language parsing precludes more precise identification of the line(s) causing the issues?

The Antlr language file for TSQL from https://github.com/teverett/grammars-v4/tree/master/sql/tsql is big and complex and therefore, I'm assuming, generates more complex C++ files with antlr-4.11.1-complete.jar.  I suppose a possible route is to start with very simple language files and check the compilation of the resulting C++ source files, and to keep adding complexity till the compilation errors start?

For me, that's a project for another day, I'm afraid.

Thanks for taking the trouble to respond to my questions.... very much appreciated!

Pete

Terence Parr

unread,
Sep 5, 2022, 2:02:11 PM9/5/22
to antlr-di...@googlegroups.com


> On Sep 5, 2022, at 10:57 AM, Peter Boulton <peters...@gmail.com> wrote:
>
> Hi Ter,
>
> I definitely feel your pain! :-(

:)

>
> It is certainly the case that a trivial coding typo or error on one line of a C++ project can generate hundreds of errors. As a C++ developer, that's why I typically build frequently and can reverse out changes till I locate the issue that's stopping the compile. I'd assumed this issue relates to C++ being a compiled language - or is it just that the language parsing precludes more precise identification of the line(s) causing the issues?

The compiler isn’t the problem I’m afraid, it’s the complexity of the language. No one person understands it according a guy i know on C++ committee.
:(

Ter
Reply all
Reply to author
Forward
0 new messages