Recipes
One page per task. Each recipe answers a single question and opens with the command that answers it.
- Generate compile_commands.json for a Makefile project
- the main recipe: plain Make, autotools, incremental and parallel builds, recursive Makefiles, and recovering a database without running the build.
- Generate compile_commands.json for a CMake project - when CMake’s own export is enough, and when it is not.
- Bear produces an empty compile_commands.json
- what to check when the file comes out empty or short.
- Set up clangd for a project without CMake - point your editor at the database once Bear has written it.
- clangd has no compile command for a header - when to let clangd infer one, and when to have Bear synthesize it.
- Use Bear with ccache, distcc, or icecc - keep a compiler launcher in the build while Bear still records the real compiler invocation.
- Run Bear inside a Docker container - capture a build that runs inside a container.
Toolchains
- Generate compile_commands.json when cross-compiling - a target-prefixed GCC or Clang.
- Generate compile_commands.json for an STM32 or arm-none-eabi project - the bare-metal Arm GCC toolchain.
- Use Bear with a vendor embedded toolchain - QNX, Microchip XC8 / MPLAB X, and Texas Instruments.
- Generate compile_commands.json for an Emscripten project -
compiling to WebAssembly with
emcc/em++. - Generate compile_commands.json for a CUDA project -
nvccalongside a host compiler. - Use Bear with Intel oneAPI compilers - the oneAPI and Classic Intel C/C++/Fortran drivers.
- Use Bear with Cray and NVIDIA HPC compilers - HPE Cray’s and NVIDIA’s HPC SDK drivers.
- Generate compile_commands.json for an MPI project - the
mpicc-style wrappers.
Related pages: Getting started with Bear for the first run, Troubleshooting for a database that came out wrong, and How Bear works for the mechanism.