GCOV Coverage analysis for C/C++ doesn't show

I couldn’t get SonarQube Code Coverage analysis to show coverage.

Sonar Scanner: 5.0.1
SonarQube Server: 9.9.0
gcovr 5.2

The project is very similar to this example:


  • cmake configure
  • "${SONAR_BUILD_WRAPPER_CMD} cmake --build ...
  • ctest
  • gcovr --root ${SOURCE_DIR} --print-summary --sonarqube -o coverage.xml .


sonar-scanner \
  --define sonar.cfamily.build-wrapper-output="${BUILD_WRAPPER_OUT_DIR}" \
  --define project.settings=sonar-project.properties \
  --define sonar.cfamily.gcov.reportsPath=${BUILD_DIR}


00:39:29  INFO: SonarScanner
00:39:29  INFO: Java 17.0.7 Eclipse Adoptium (64-bit)
00:39:29  INFO: Linux 5.13.0-1031-aws amd64
00:39:29  INFO: User cache: /home/build/.sonar/cache
00:39:30  INFO: Analyzing on SonarQube server
00:39:30  INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
00:39:30  INFO: Load global settings
00:39:30  INFO: Load global settings (done) | time=61ms
00:39:42  INFO: Sensor gcov [cpp]
00:39:42  INFO: Sensor gcov [cpp] (done) | time=52ms
00:39:42  INFO: Sensor JaCoCo XML Report Importer [jacoco]
00:39:42  INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
00:39:42  INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer

Has anyone encountered a similar issue with SonarQube Code Coverage analysis not displaying coverage, and if so, are there any suggestions or solutions to resolve this problem?

Hi @mkilivan and welcome to the community!

It seems to me that you are trying to use sonar.cfamily.gcov.reportsPath property in conjunction with generic SonarQube XML files. .gcov and SonarQube-compatible XML are different formats for test coverage information, and they have to be specified using different scanner properties:

  • sonar.cfamily.gcov.reportsPath expects a directory that contains .gcov files generated using the gcov tool. An example for using this property is available here. Note that this example doesn’t use gcovr.
  • sonar.coverageReportPaths expects a generic SonarQube XML test data file. One common way to generate such a file for C and C++ is to use gcovr’s --sonarqube flag. An example for using this property is available here.

Since you have already generated a coverage.xml file using gcovr, I would suggest using the sonar.coverageReportPaths property instead of sonar.cfamily.gcov.reportsPath.

I hope this helps and let us know if you have any further questions!

Best regards,


Thank you Michael, using sonar.coverageReportPaths property fixed the issue.

Many thanks!

1 Like

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