Compilation_database does not work as expected

On SonarQube Server, I have weird behavior with the recommended “compilation database” scanning mode (for cfamily).

Indeed, if I create this database through cmake (Analysis modes | SonarQube Server Documentation) or through the build-wrapper (CFamily prerequisites | SonarQube Server Documentation), then the cpp files are analyzed BUT they did not found any “classes/statement/function”. At the same time, the number of issues found is quite low.

  • Windows environment
  • same environment variables between call to cmake/build-wrapper and sonar-scanner
  • msvc 2017 or 2019 targeted
  • I have checked the compilation_database.json and they are consistent

If I use « AutoConfig », then the number of classes and issues found is a lot more consistent.

I would like to use compilation_database mode in order to provide all the necessary macros/includes/variants.

Any ideas are welcome

Best Regards

I’m not sure what you mean here. Can you show some examples (screenshots, logs)?

Please also confirm what version of SonarQube Server you’re using, as noted in the template post.

Thanks for your interest,

This shows the log output when it works (15 classes, 59 functions, …) while in AutoConfig.

When I am using compilation database I have 0 classes and 0 functions…

The SonarQube Server version is " Enterprise Edition v2025.1 (102418)"

Best Regards

Thanks! Some of these logs must be new – they’re new to me! :slight_smile:

I have a feeling that our devs are going to want to see your compilation database – so I’ll ping them on this thread and somebody will be along and open a private message with you.

2 Likes

Thanks for your help,
Finally, the most painful was the fact that the compile commands should be created from the “true folder” and the analysis launched from the same “true folder”.
Indeed I was working from a “linked folder”.

1 Like