Skip to content

fix(gql): define ANTLR4CPP_STATIC for Windows builds - #58

Merged
adsharma merged 1 commit into
mainfrom
gql-windows-antlr4-static
Aug 15, 2026
Merged

fix(gql): define ANTLR4CPP_STATIC for Windows builds#58
adsharma merged 1 commit into
mainfrom
gql-windows-antlr4-static

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Problem

The GQL extension links antlr4_runtime, which is built as a static library (see third_party/antlr4_runtime/CMakeLists.txt). On Windows its headers default to __declspec(dllimport) unless ANTLR4CPP_STATIC is defined.

The GQL object libraries compile their sources without that define, so MSVC emits references to a non-existent ANTLR DLL for inline/compiler-generated members. This surfaces as:

gql_function.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl antlr4::tree::AbstractParseTreeVisitor::shouldVisitNextChild(class antlr4::tree::ParseTree *,class std::any const &)"
gql_function.cpp.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl antlr4::tree::AbstractParseTreeVisitor::~AbstractParseTreeVisitor(void)"

Fix

Define ANTLR4CPP_STATIC for the gql extension, so those members are emitted locally in the extension's own TUs. This matches how the core library builds its own ANTLR consumers (src/CMakeLists.txt).

Linux/macOS builds are unaffected — ANTLR4CPP_STATIC is only consulted in the MSVC branch of antlr4-common.h.

antlr4_runtime is built as a static library, but on Windows its headers
default to __declspec(dllimport) unless ANTLR4CPP_STATIC is defined. The
GQL object libraries compile without that define, so MSVC emits references
to a non-existent ANTLR DLL for inline/compiler-generated members such as
AbstractParseTreeVisitor::shouldVisitNextChild and its destructor, producing
LNK2001. Define ANTLR4CPP_STATIC for the gql extension, matching the core
library's own ANTLR consumers (src/CMakeLists.txt).
@adsharma
adsharma merged commit 7ee11fd into main Aug 15, 2026
2 checks passed
@adsharma
adsharma deleted the gql-windows-antlr4-static branch August 15, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant