Sonar-scanner fails c/c++/Objective-c due to missing build-wrapper?

Using sonarqube developer 7.9.1 on Ubuntu linux to analyze our c and c++ source code and I get an error about a missing build wrapper when running sonar-scanner. Found something in the documentation about getting a build wrapper but no link and I’m not sure I’m finding what I am looking for. Can you help?

Here’s the command I run:

sonar-scanner -Dsonar.projectKey=SG -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=458cbb3d38315123d84da6c1fcf3f152f609c0c9 -X

Here is the end of the output from this command:

15:42:16.155 INFO: ------------------------------------------------------------------------
15:42:16.155 INFO: EXECUTION FAILURE
15:42:16.155 INFO: ------------------------------------------------------------------------
15:42:16.155 INFO: Total time: 1:05.651s
15:42:16.209 INFO: Final Memory: 21M/74M
15:42:16.210 INFO: ------------------------------------------------------------------------
15:42:16.210 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException:

The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
and setting the property "sonar.cfamily.build-wrapper-output", but it was not specified.

If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:

    sonar.c.file.suffixes=-
    sonar.cpp.file.suffixes=-
    sonar.objc.file.suffixes=-


        at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:116)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
sonarqube@a54ea872c843:/work/swineguard_2.0$

Hi @jmelter,

you can follow the documentation page for C/C++: https://docs.sonarqube.org/latest/analysis/languages/cfamily/.

All steps are described there, how to get build-wrapper and how to properly invoke the analysis.

Thanks, yes I found and solved this issue yesterday. Didn’t get there until late in the day because I had some re-compile issues to fix before the build-wrapper would work. Finally got one pass of analysis through our source code complete!

…then we found out about SonarCloud. Seems like this would have been more useful to find a week ago when I started this SonarQube setup. We are now evaluating both to determine which is the best fit for us. We need to understand the usability feature differences between the two (we already know SonarQube is the on-prem solution and SonarCloud is the cloud solution).

1 Like