I'm trying to build my first clang AST tool on windows 10. I want develop on visual studio code in c++ - I can live with any compiler that works...
I've looked at the clang documentation , YouTube videos and stack overflow and - I'm still no there?
I finally got the "tools/extra/ToolTemplate.cpp" example to pass the compile by
- Installing visual studio studio community 22022
- installing mysys2 and mingw - using the cmake kit rfom mingw (g++.exe (MinGW.org GCC-8.2.0-3) 8.2.0)
- building using cmake build from studio code
Now I'm failing the build with undefined references such as
clang::tooling::AtomicChange::AtomicChange(
clang::NamedDecl::getQualifiedNameAsString
clang::tooling::ExecutionContext::reportResult
clang::ast_matchers::MatchFinder::MatchCallback::~MatchCallback()
llvm::sys::PrintStackTraceOnErrorSignal
clang::tooling::createExecutorFromCommandLineArgs
llvm::errs
llvm::toString[abi:cxx11]
clang::ast_matchers::MatchFinder::MatchFinder
and more....
There are so many libraries in the binary, and I see no documentation as to which API is is which library. What am I missing (apart from the correct libraries) - cmakd ast looks like a great concept - is it really so hard to get started or did I miss the full tutorial?
The link line is
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\ucrt64\bin\g++.exe -g CMakeFiles/canalDoc.dir/main_clang.cpp.obj -o canalDoc.exe -Wl, --out-implib,libcanalDoc.dll.a -Wl,--major-image-version,0, --minor-image-version,0 -LC:/install/clang+llvm-18.1.8-x86_64-pc-windows-msvc/lib -lclangAST -lclangASTMatchers -lclangBasic -lclangFrontend
-lclangSerialization -lclangTooling -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
The CMakeLists.txt file is
cmake_minimum_required(VERSION 3.5.0)
project(canalDoc VERSION 3.5.0 LANGUAGES C CXX)
include_directories(C:/install/clang+llvm-18.1.8-x86_64-pc-windows-msvc/include)
link_directories(C:/install/clang+llvm-18.1.8-x86_64-pc-windows-msvc/lib)
add_executable(canalDoc main_clang.cpp)
target_link_libraries(canalDoc
PRIVATE
clangAST
clangASTMatchers
clangBasic
clangFrontend
clangSerialization
clangTooling
)