I use SonarQube to analyze C++ project, but it failed

Must-share information (formatted with Markdown):

Hello @judy,

Welcome to the community!

Can you run the scanner with --debug and attach the full result instead of a screenshot.

Thanks

hi, thanks for your quick response, I try to restart my computer to fix this issue, and then re-run StartSonar.bat, but I got another issue
image
why is that? does that mean the last error I meet is because of the Sonar server does not start?

The second error is probably because of your java version. SonarQube 8.0 requires at least java 11 and you are using java 8.

in my desktop, I installed jre 7 and java 11, and I also config the environment variable and point to java 11, i am not sure why it still find the jre7, and now I uninstall the jre7, another issue happened, but previously, it worked, i only install the jre 7 because other application depends on it, and now i uninstalled it, but it still didn’t work.

I fixed that issue, now I can start Sonar server, and can also build my project using wrapper, and when run scanner, it failed, here I attached the log file, pls help me to identify the problems.

log.txt (81.7 KB)

This exception means that the build-wrapper-dump.json was not found in the specified directory.

  • Verify that the build-wrapper-win-x86-64.exe is running successfully.
  • Validate that build-wrapper-dump.json is generated in the specified --out-dir.
  • Make sure to set sonar.cfamily.build-wrapper-output in the sonar-project.properties to the specified --out-dir.

Yes, I have run wrapper successfully, and here is the build-wrapper-dump.json, and build-wrapper.log, and I also set the wrapper-output in the sonar-project.prop. I can not attach .json and .log file file here, so I modified the .json and .log to .txt. build-wrapper-dump.txt (787.0 KB) erties.
build-wrapper.txt (967.5 KB)
image

Replace in the sonar-project.properties C:\output with C:\\output or C:/output

I changed to C:/output it still failed.![error|365x500](upload://bClajNmvo8SRlog.txt (598.9 KB) Z8w0uGMo

8AJ4K5k.png)

You are not running the scanner from your project directory as before.
You should run it from C:\6.20_FTAE_Latest\FTAE_Src\Src\FTAE\RnaAlarmDetector.

Please try to look at the log and the error message before posting.

![config|39

7x180](uploalog.txt (81.8 KB) d://8o0mHKFuG9HBoVwJXky7zK5RYOB.png)

Okay now you are finding the build-wrapper json file. The issue now is that you are not using a supported compiler. You can find the list of supported compilers here:https://www.sonarsource.com/products/codeanalyzers/sonarcfamilyforcpp.html

You are using a wrapper around MSVC. If your wrapper compiler fully mimics the interface of Microsoft compiler, we will not see any difference, and the analysis might work, even if it’s not supported.
But in your case, it isn’t. For example, when we execute CL.exe to get the compiler version we expect something like this:

Microsoft ® C/C++ Optimizing Compiler Version 19.23.28106.4 for x86
Copyright © Microsoft Corporation. All rights reserved.

In your case, we are getting:

CoverageScanner © froglogic GmbH\r\nUsage:\r\n–cs-statement-block: code coverage of statement blocks support\r\n–cs-decision: code coverage decision…

1 Like

I am using VS2017 compiler, and use MSBuild to generate wrapper.json, I am not sure why you are saying I am using the wrong version, so what should i do for next step? change the wrapper version? or upgrade compiler?

I am using SquishCoCo to do our code coverage, I will uninstall it to try, but in my company, we should use SquishCoCo to do code coverage, does that means SonarQub can not be coexist with SquishCoCo?

after uninstall SquishCoCo, I can analyze my code successfully. Thank you for you support!

As I said you are not using MSVC. You are using a compiler wrapper to MSVC (provided by SquishCoCo).
From SquishCoCo doc:

Squish Coco provides also a replacement of the native compiler called wrapper which extends…

you only have to change your system PATH to point to the real cl.exe instead of the wrapper one.

They can coexist but you have to run SquishCoCo in a different way(you shouldn’t use the wrapper). You can use their coveragescanner explicitly. You can check their docs for more details.

Great!

1 Like