Search code examples
c++visual-studioclangpowertools

How can you generate a JSON compilation database using the CLI?


As described here one can generate a JSON compilation database using the UI of Visual Studio. Is it possible to do this in the CLI?

(The use case for this is to use the database with clangd to provide autocompletion to another editor)


Solution

  • Apparently there is a powershell script that can be used like this:

    clang-build -export-jsondb
    

    If this generates a compile_commands.json file in the current directory of the projects in current directory.