"build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files for multiple projects

We have faced this analysis error;

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • you are correctly invoking the scanner with correct configuration
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • you are providing the path to the correct build-wrapper output directory
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps

Our multi project C++ structure in like below; when we compile project create build_dir in project_root path. All modules compiles and theirs object files occurs in build_dir.

Project_Root
 ├── 
   Common
   Thirdparty
   Sourcedirectory_X
      ├── X
                ├── x_feature.cpp
     ├── CmakeList.txt
   Sourcediretory_Y
      ├──Y
                ├── y_feature.cpp
      ├── CmakeList.txt
  Source_directory_Z
     ├── Z
               ├── z_feature.cpp
     ├── CmakeList.txt
  CmakeList.txt
  build_dir
        ├── X (includes object file)
        ├── Y
        ├── Z

We followed this guides.
https://docs.sonarqube.org/latest/analysis/languages/cfamily/
SonarScanner | SonarQube Docs (Running SonarScanner from the zip file)
We have created project as manually and set it according to local on sonarqube.

Firstly we want to analysis only project X module

Build Wrapper command;

cd build_dir

build-wrapper-linux-x86-64 --out-dir ./bw-output make Target_X -j3

Sonarscanner;

        sonar-scanner \
          -Dsonar.projectKey=my_project \
          -Dsonar.sources=X \
          -Dsonar.cfamily.build-wrapper-output=build_dir/bw-output \
          -Dsonar.projectBaseDir={Project_Root_Path} \
          -Dsonar.host.url=http://.........:9000 \
          -Dsonar.login=....................................

According to output log, sonar scanner can’t be find source file. Maybe Sonar scanner needs to object file? Each modules source files (.cpp) are exist in the own project directory. But object file exist in the Project_Root/build_dir.
Should source and object files be under the own project directory path?

Welcome to the community! @betulaslan,

As there are multiple reasons why build wrapper may be empty, would it be possible for you to share the build-wrapper.log and build-wrapper-dump.json files for the investigation?

Few most common situations:

  1. When build wrapper was invoked, was it done on clean build? It is possible for build wrapper to not register any compiler invocation if make didn’t need any changes.
  2. What compiler and SonarQube do you use? It is possible that the compiler is not supported or not supported in the given version.
  3. What hardware/OS are you using. The build-wrapper is currently not supported on M1 MacOs.

Thanks we have solved issue.

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