Building antlr4 project in cpp

  antlr4, c++, cmake

I’m using antlr4-4.9.2 on Windows 10. I want to use antlr4 in c++, and here’s part of my CMakeLists.txt

file(GLOB antlr4-cpp-src
    third_party/antlr4-cpp-runtime-4.9.2/src/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/atn/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/dfa/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/misc/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/support/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/tree/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/tree/pattern/*.cpp
    third_party/antlr4-cpp-runtime-4.9.2/src/tree/xpath/*.cpp
)
add_library (antlr4-cpp-runtime ${antlr4-cpp-src})
add_executable(MiniSql ${src_dir} src/main.cpp)
target_link_libraries(MiniSql antlr4-cpp-runtime)

But I got 171 errors and warnings. For example, in BufferedTokenStream,

TokenSource *BufferedTokenStream::getTokenSource() const
{
    return _tokenSource;
}

got reference to TokenSource is ambiguous.
And many more like this.
What’s my problem in the code?

Source: Windows Questions C++

LEAVE A COMMENT