Sonar-scanner, GitLab, C language problem

I am trying to analyze with SonarQube a C program written using Visual Studio 2022 IDE.
In my development environment I have added the Clang Power Tools extension in order to generate the compilation database (compile_commands.json file) and the sonarlint extension for Visual Studio run smoothly without problems.

The problem arise when I push the “solution” on my GitLab server that is integrated with the SonarQube server (Developer Edition). During the execution of the CI I got:

ERROR: Error during SonarScanner execution

[187]( The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

[188]( * you are correctly invoking the scanner with correct configuration

[189]( * your compiler is supported

[190]( * you are providing the path to the correct Compilation Database JSON

[191]( * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps

[192]( at com.sonar.cpp.plugin.CFamilySensor.process(

[193]( at com.sonar.cpp.plugin.CFamilySensor.execute(

The GitLab server and the GitLab agent used to execute the CI (as shell command, not using docker) are installed on a Ubuntu machine and all stuff updated to the latest version.

Here is a snippet of compile_commands.json:

    "directory": "C:/Users/<edited>/Desktop/Solution/",
    "command": "\"C:/Users/<edited>/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c \"C:/Users/<edited>/Desktop/Solution/Solution/main.c\" -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -m32 -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_CRT_SECURE_NO_WARNINGS\" \"-DWIN32\" \"-DNDEBUG\" \"-D_LIB\" \"-D_CRT_SECURE_NO_WARNINGS\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/cppwinrt\"",
    "file": "C:/Users/<edited>/Desktop/Solution/Solution/main.c"

Here is a snippet of


The .gitlab-ci.yml is a quite simple script where sonar-scanner is invoked using:

    - shell
  stage: test
    GIT_DEPTH: "0"  
    key: "${CI_JOB_NAME}"
      - .sonar/cache
      - /opt/sonar-scanner/bin/sonar-scanner -Dsonar.projectVersion=${CI_COMMIT_BRANCH}
  allow_failure: true
      - main

Product versions list:

  • SonarQube: Developer Edition Version 9.4 (build 54424)
  • sonar-scanner:
  • Visual Studio 2022: 17.2.1
  • SonarLint for Visual Studio 2022:
  • Clang Power Tools 2022:

Someone have any idea how to solve this problem?

Thank in advance…


Hello @Dos622,

I assume that you are pushing the locally generate compile_commands.json to your repo.
When you run the scanner with compilation database, we analyze the translation units that have entries in the JSON.

The compilation database contains absolute paths, So if you generate it locally you cannot use it for the CI since the file will have different paths. That is why the log says that no files were analyzed; it wasn’t able to match any file due to different absolute paths.

You should be able to fix the issue by generating the compilation database on your CI instead of the local machine or adjusting all paths in the compilation database to reflect the CI paths(not recommended because it might get quickly out of sync.)


Thank Abbas, but this is not a solution … I am compiling the source on Windows with Visual Studio and my GitLab server is on Ubuntu … I cannot recompile the solution there (at least … I’m not aware that I can …).

At present time seems that the only solution is to run sonar-scanner on the development machines.

Please let me know if you are aware of any other possibile solution.



The environment from where you launch the analysis should build-ready. The analyzer access many of the component used(in case of build-wrapper) or gonna be used(in case of compilation database) to preforms the analysis.

Doing analysis from an environment where you cannot generate compilation database(hence you cannot build your project) is not supported.

Let me know if you have further questions,

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