Sonar Scanner CLANG - windows include files (ie stdio.h) file not found

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

Sonarqube: * Enterprise Edition * Version 8.7 (build 41497)
SonarScanner 4.6.2.2472
Language CLang
build-wrapper-win-x86-64.exe, version 6.17

05:15:17.633 INFO: [pool-1-thread-1] C:/Sonar/Generated/CLang/WebService/VS2019/XXXXX/XXXXX.c
05:15:20.180 DEBUG: [pool-1-thread-1] C:\Opt\gsoap-2.8\gsoap\stdsoap2.h:623 'stdlib.h' file not found
05:15:21.348 INFO: [pool-1-thread-1] C:/Sonar/Generated/CLang/WebService/VS2019/XXXXX/XXXXX.c
05:15:21.585 DEBUG: [pool-1-thread-1] C:\Opt\gsoap-2.8\gsoap\stdsoap2.h:623 'stdlib.h' file not found

For some reasons the environment include files couldn’t be found.
in Json file, there is set “include” but just being ignored during analysis.

"include=C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\ATLMFC\\include;C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\include;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\cppwinrt;C:\\FND32\\include;C:\\FND32\\sinclude",

Include files are found when I tried to specify each directory as additional includes “/I” by manually editing the json file.
"\/IC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\ATLMFC\\include","\/IC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\include","\/IC:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um","\/IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt","\/IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\shared","\/IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\um","\/IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\winrt","\/IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\cppwinrt","\/IC:\\FND32\\include","\/IC:\\FND32\\SINCLUDE",

Please help, not sure what i missed.

Thanks,
Lea

Hello @lea.i.abrugena,

Can you confirm that your project builds successfully when you do not use the build-wrapper?
If so, could you share:

  • build-wrapper.log
  • build-wrapper-dump.json
  • output of the command sonar-scanner -X

please? I can send you a PM if needed

Hi Amelie, Thanks for the response.

Yes, I am sure that project is built successfully.

Please see attached file for build-wrapper, json, and sonar-scanner.
bw_output.zip (25.0 KB)

Thanks,
Lea

Hello @lea.i.abrugena ,

If I understand correctly your problem: the build command with the build-wrapper succeeds, as well as the sonar-scanner command (you can see that your code was analyzed in your SonarQube instance).
But because stdlib.h was not found, the results of the analysis may be inaccurate for some files.
Am I correct?

I can see in the logs that a reproducer was generated. Could you send me the following please:

  • the full path to the file
    stdlib.h
  • the file
    C:\Sonar\Generated\CLang\sonar-cfamily-reproducer.zip

Thank you

Hello @Amelie,

Yes you are correct, all succeeds and the result is displayed in Sonarqube Dashboard.
But when i tried to workaround the missing *.h files like what i mentioned on my original request, there were 5 bugs detected which were not reported originally. So, it seems that i really need to fix it to get more accurate results.

The full path of stdlib.h is C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\stdlib.h

Please see sonar-cfamily-reproducer.zip attached
sonar-cfamily-reproducer.zip (53.1 KB)

Thanks,
Lea

What you say totally makes sense: when we can’t find stdlib we don’t have enough information to find the 5 bugs you mention. So indeed it would be better if we can fix the problem, to have a more precise analysis.

Would you be able to update your SonarQube to the 8.9 version (latest LTS) or to the latest version 9.0, please? The one you’re currently using (8.7) is not supported anymore.

Hello @Amelie,

At current time, upgrading to version 8.9 (latest LTS) is not possible. I reached out to our support team and this is not yet their current priority.
I am hoping that there’s something else we can do to workaround my issue.

Thanks,
Lea

Hello @lea.i.abrugena ,

First, let me apologize for the delay.

The issue seems to come from the fact that while overriding the environment variable INCLUDE so that it contains specific things you need, you modify the way it is written. So it is written in lower cases in your case (include) when it is usually in upper cases (INCLUDE).
We created a ticket to handle this: CPP-3206.

In the meanwhile, keeping INCLUDE in upper cases should fix the problem.

HTH,
Amélie

Wow Thank You @Amelie!
I changed my environment variable (include) to upper case (INCLUDE) and it works. There were no more missing libraries. I’m glad you created a ticket for this.

Best Regards,
Lea

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