Sonar-scanner failing for a C/C++ package


We recently purchased Sonarqube developer edition. After preliminary testing, we ran Sonarqube for a set of packages in one of our product. In this, Sonarqube scanner step is continuously failing for a package ‘sam’ (C/C++). Please find below the steps that we used for the Sonarqube analysis:

build-wrapper, version 6.15 (linux-x86)

Developer Edition Version 8.6.1


  1. cd /code/monitoring/sam (Package path under which the Makefile exists)
  2. /opt/sonarqube/bin/build-wrapper-linux-x86-64 --out-dir /output/ make RELEASE=true ROOT=/code/buildroot P4CHANGENUM=100000 [SUCCESS]
  3. /opt/sonarqube_cli/bin/sonar-scanner -Dsonar.projectKey=VXOA.sam’<sonar_url>’ -Dsonar.login=*** -Dsonar.password=*** [FAILURE]

Error we face:

[2021-02-20T15:03:04.191Z] ERROR: Error during SonarScanner execution
[2021-02-20T15:03:04.191Z] java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed.

Note: Sonarqube analysis is done inside Centos 7 docker container.

When I checked the ‘/output/build-wrapper-dump.json’ file, I am able to see the C/C++ file analysis information for the ‘sam’ package. Can anyone help me in identifying this issue?

Thank you!

Hi @balamurugan.r, welcome to the SonarSource Community!

This stands out to me as a likely source of your problem. The analysis must be conducted on the same host used for the wrapped build; mismatches in paths on the host environments often prevent us from identifying files seen during the build as “the same” as files encountered by the analyzer and leads to your error.

Both the commands ‘build-wrapper-linux-x86-64’ and ‘sonar-scanner’ are run inside the same container environment and inside the same path (successively in the same shell session).

Steps (All steps are run inside the Centos 7 container where the source code path is mounted):

  1. cd /code/monitoring/sam (Package path under which the makefile exists)
  2. /opt/sonarqube/bin/build-wrapper-linux-x86-64 --out-dir /output/ make RELEASE=true ROOT=/code/buildroot P4CHANGENUM=100000 [SUCCESS]
  3. /opt/sonarqube_cli/bin/sonar-scanner -Dsonar.projectKey=VXOA.sam’<sonar_url>’ -Dsonar.login=*** -Dsonar.password=*** [FAILURE]

Will you attach the following?

  • a zip of the outputs in /output
  • a log of the output from sonar-scanner (with DEBUG-level logging preferably) (142.5 KB)

@Jeff_Zapotoczny I have attached the with this reply.

Scanner command stdout and stderr output (scanner_stderr.log & scanner_stdout.log) is also bundled with the zip file.

Scanner command ran in debug mode. Command:

/opt/sonarqube_cli/bin/sonar-scanner -X -Dsonar.verbose=true -Dsonar.log.level=DEBUG -Dsonar.projectKey=VXOA.sam'<url>' -Dsonar.login=**** -Dsonar.password=***

I’m seeing a misalignment in the directories involved in build vs. analysis.

The build wrapper is seeing absolute paths such as

Whereas it appears that analysis is being triggered from within a subdirectory:

04:37:32.756 INFO: Project root configuration file: /code/monitoring/sam/
04:37:48.193 INFO: Base dir: /code

For successful analysis, it’s best if all the code is organized to live within a common parent directory, that the build-wrapper and sonar-scanner both be invoked from this directory, and that this is where the lives.

Yeah I understand @Jeff_Zapotoczny but these other directories like ‘cpp-libs’ are common library paths used by multiple packages across multiple repositories. The problem here is for other packages with similar conditions, the sonar-analysis ran successfully but is failing only for this package. Even when the C/C++ code is analysed and its information is there in ‘/output/build-wrapper-dump.json’ file, sonar-scanner is failing with an error “build-wrapper-dump.json file was found but 0 C/C++/Objective-C files were analyzed.” . I couldn’t understand why this error is popping when the C/C++ files are analysed successfully.

Hi @balamurugan.r ,

did you manage to solve your issue? Shall I consider this topic as closed?