CPP Project with Clang++ and Qibuild: 0 compilation units analyzed

Hello,

I am trying to analyse a CPP project but I get « 0 compilation units analyzed »

The sources are split amongst a dozen of directories and is build with Clang++ through Qibuild in a CentOS 7 Docker container.

Versions:

  • Sonarqube 6.7.5

  • Sonarqube Scanner 3.0.3.778

  • Clang++ 3.9.0

  • Qibuild 3.11Hello.17

The « sonar.sources » property contains a comma separated list of the sources directory, and the file « build-wrapper-dump.json » is generated. The analysis is successful, althought no issue shows up in Sonarqube (and there should be some :))

The documentation here https://docs.sonarqube.org/display/PLUG/Building+on+Linux says « Make sure your source tree is in a directory called ‘src’ »: is it only for the sample or does it mean that all the source files needs to be in the same directory?

Thank you for your help

Hello @glucazeau,

is build-wrapper launched inside the docker container or is the build-wrapper wrapping something which invokes the docker container?
build-wrapper and files compilation must be on the same layer, not split between host and container.

Hello Massimo,

The build-wrapper is launched inside the container, both wrapper and sources are in a mounted volume

So you’re saying that the Sonar build wrapper should be in the Docker container? I am going to try

Edit:
@mpaladin I have put the Sonar wrapper in the Docker image used to compile the code but it didn’t change anything, still “0 compilation units analyzed”. I forgot to say that Sonarqube shows duplicated code though (even before this change)

Hello @glucazeau,

could you provide the build-wrapper.log file?

Is there a way to send it with a private message? I’d rather not leave it here

Thank you
Guillaue

Hi @glucazeau,

sure, I sent you a PM.

For the records the issue was coming from the fact that build-wrapper build and and sonar-scanner analysis were not executed on the same instance (machine/container). It is a requirement to have both of them on the same instance to have the C/C++ analyser to be able to access all dependencies libraries and files used during build.

1 Like