# Add "${ROOTSYS}/compile\_flags.txt" files to "official" ROOT binary releases

**URL:** <https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502>\
**Category:** ROOT\
**Tags:** build\
**Created:** [April 6, 2022, 4:42pm UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502 "2022-04-06T16:42:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 6, 2022, 4:42pm UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502/1 "2022-04-06T16:42:07Z")

</div>

I’ve recently started to play with adding [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) support to my editor.  
For C++ code, I am trying to use the [clangd](https://clangd.llvm.org/installation.html) 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).

```bash
#!/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”.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [April 19, 2022, 11:44am UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502/2 "2022-04-19T11:44:27Z")

</div>

Hello @Wile_E_Coyote ,  
thank you for the suggestion, feel free to open a feature request at [Sign in to GitHub · GitHub](https://github.com/root-project/root/issues/new/choose) if you want this to be tracked.

CC: @Axel

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [April 20, 2022, 9:36pm UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502/3 "2022-04-20T21:36:46Z")

</div>

Interesting idea. QtCreator C++ LSP ([Using Language Servers | Qt Creator Manual](https://doc.qt.io/qtcreator/creator-language-servers.html)) will also be based on clangd soon [Qt Creator and clangd: An Introduction](https://www.qt.io/blog/qt-creator-and-clangd-an-introduction) so it would be a nice feature for it, too. See other integration options in [Coding in ROOT with the horsepower of an F1 - ROOT](https://root.cern/blog/code-horsepower-f1/)

> [@Wile\_E\_Coyote](#):
>
> “`${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).

Maybe it’s better to have the JSON variant, as it can be enabled by just adding one flag to CMake when building

```auto
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 20, 2022, 9:48pm UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502/4 "2022-04-20T21:48:10Z")

</div>

The “`compile_commands.json`” file will only work if you build ROOT yourself and you keep the “source” and “build” directories.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 4, 2022, 9:48pm UTC](https://root-forum.cern.ch/t/add-rootsys-compile-flags-txt-files-to-official-root-binary-releases/49502/5 "2022-05-04T21:48:23Z")

</div>

Closed on May 4, 2022, 9:48pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
