I’ve recently started to play with adding Language Server Protocol (LSP) support to my editor.
For C++ code, I am trying to use the clangd language server.
It turns out that there are problems with ROOT binary releases.
One gets various errors in form, e.g.:
#include "TRandom.h" In included file: 'ROOT/RConfig.hxx' file not found with <angled> include; use "quotes" instead
#include <ROOT/RConfig.hxx> In included file: 'RConfigure.h' file not found
It seems I have found a simple fix (for binary releases), shown below.
One needs to create a simple “${ROOTSYS}/compile_flags.txt
” file.
Could you, please, add the procedure which automatically creates appropriate “${ROOTSYS}/compile_flags.txt
” files into your procedure that creates the “official” ROOT binary releases (note: this file should not be made if there exists a “${ROOTSYS}/compile_commands.json
” file).
#!/usr/bin/env bash
if [ -n "${ROOTSYS}" ] ; then
COMPILE_COMMANDS="${ROOTSYS}/compile_commands.json"
COMPILE_FLAGS="${ROOTSYS}/compile_flags.txt"
if [ ! -e "${COMPILE_COMMANDS}" -a ! -e "${COMPILE_FLAGS}" ] ; then
echo "--language=c++" > "${COMPILE_FLAGS}"
echo "$(root-config --auxcflags)" | sed 's/ /\n/g' >> "${COMPILE_FLAGS}"
echo "-Iinclude" >> "${COMPILE_FLAGS}"
touch -h -r "${ROOTSYS}/bin" "${COMPILE_FLAGS}" "${ROOTSYS}"
fi
fi
Note that one may need to remove some flags, which the “root-config --auxcflags
” call returned, that are not valid “Clang command line arguments”.