[Qbs] MSVC based profile: how SDK detection is working?

Heiko Nardmann heiko.nardmann at itechnical.de
Fri Mar 7 13:33:17 CET 2025


Hi Jochen,

the link https://qbs.io/docs/qml-qbsmodules-cpp/#windowsSdkVersion-prop 
states

    "By default, the latest SDK is used."

How is the latest one determined? Just by not passing any version to 
vcvarsall.bat?

My concrete problem is:

    C:\Programs\QtCreator\11.0.8\share\qtcreator\qbs\share\qbs\imports\qbs\Probes\MsvcProbe.qbs:52:16
    Could not run
    C:/Programs/mvs17/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
    (Process crashed)

Currently I'm looking for a way to see the actual commandline used for 
cl.exe. To reproduce the crash ...

Maybe an important detail: this is part of a docker image resp. is 
crashing inside a docker container. Running cl.exe standalone looks fine:

     > C:/Programs/mvs17/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
    Microsoft (R) C/C++ Optimizing Compiler Version 19.43.34808 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.

    usage: cl [ option... ] filename... [ /link linkoption... ]

I've created some dummy file like in MSVC::determineCompilerVersion; 
looks good as well:

     >
    C:/Programs/mvs17/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
    /nologo /EP qbsXXXX.cpp
    qbsXXXX.cpp

    194334808


Based on what I've found inside "retrieveInstancesFromVSWhere()" the 
vswhere command returns:

     > "C:\Program Files (x86)\Microsoft Visual
    Studio\Installer\vswhere.exe" -products
    Microsoft.VisualStudio.Product.BuildTools -format json -utf8
    [
       {
         "instanceId": "3fd400c3",
         "installDate": "2025-03-07T06:22:46Z",
         "installationName": "VisualStudio/17.13.2+35825.156",
         "installationPath": "C:\\Programs\\mvs17",
         "installationVersion": "17.13.35825.156",
         "productId": "Microsoft.VisualStudio.Product.BuildTools",
         "productPath":
    "C:\\Programs\\mvs17\\Common7\\Tools\\LaunchDevCmd.bat",
         "state": 4294967295,
         "isComplete": true,
         "isLaunchable": true,
         "isPrerelease": false,
         "isRebootRequired": false,
         "displayName": "Visual Studio Build Tools 2022",
         "description": "The Visual Studio Build Tools allows you to
    build native and managed MSBuild-based applications without
    requiring the Visual Studio IDE. There are options to install the
    Visual C++ compilers and libraries, MFC, ATL, and C++/CLI support.",
         "channelId": "VisualStudio.17.Release",
         "channelUri": "https://aka.ms/vs/17/release/channel",
         "enginePath": "C:\\Program Files (x86)\\Microsoft Visual
    Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
         "installedChannelId": "VisualStudio.17.Release",
         "installedChannelUri": "https://aka.ms/vs/17/release/channel",
         "releaseNotes":
    "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.13#17.13.2",
         "resolvedInstallationPath": "C:\\Programs\\mvs17",
         "thirdPartyNotices":
    "https://go.microsoft.com/fwlink/?LinkId=661288",
         "updateDate": "2025-03-07T06:22:46.1065459Z",
         "catalog": {
           "buildBranch": "d17.13",
           "buildVersion": "17.13.35825.156",
           "id": "VisualStudio/17.13.2+35825.156",
           "localBuild": "build-lab",
           "manifestName": "VisualStudio",
           "manifestType": "installer",
           "productDisplayVersion": "17.13.2",
           "productLine": "Dev17",
           "productLineVersion": "2022",
           "productMilestone": "RTW",
           "productMilestoneIsPreRelease": "False",
           "productName": "Visual Studio",
           "productPatchVersion": "2",
           "productPreReleaseMilestoneSuffix": "1.0",
           "productSemanticVersion": "17.13.2+35825.156",
           "requiredEngineVersion": "3.13.2069.59209"
         },
         "properties": {
           "campaignId": "",
           "channelManifestId": "VisualStudio.17.Release/17.13.2+35825.156",
           "includeRecommended": "0",
           "nickname": "",
           "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft
    Visual Studio\\Installer\\setup.exe"
         }
       }
    ]

I have to admit that I don't get the calls inside "getMsvcDefines()"; 
what do I need to run for them on the commandline?

    C:/Programs/mvs17/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
    /nologo /B1 %COMSPEC% /c /TC NUL set MSC_CMD_FLAGS

Probably the above is not correct?


/Kind regards,/

   Heiko
------------------------------------------------------------------------
*From:* Jochen Ulrich [mailto:jochen.ulrich at bee360.com]
*Sent:* Friday, March 7, 2025 at 8:12 AM
*To:* Heiko Nardmann
*Cc:* qbs at qt-project.org
*Subject:* AW: [Qbs] MSVC based profile: how SDK detection is working?

> Hi Heiko!
>
> The winSdkVersioninside MsvcProbe.qbsis an input which is set from the 
> cpp.windowsSdkVersionproperty (see 
> https://qbs.io//docs/qml-qbsmodules-cpp/#windowsSdkVersion-prop 
> <https://qbs.io/docs/qml-qbsmodules-cpp/#windowsSdkVersion-prop>).
>
> As it seems to me, the “detection” of the SDK version is done by MSVC 
> itself. So, if you don’t set the cpp.windowsSdkVersionexplicitly, then 
> Qbs doesn’t know which SDK version it is working with. If you set it, 
> then Qbs simply passes this to vcvarsall.batto figure out the 
> necessary environment variables (see vsenvironmentdetector.cpp, line 
> 243-244 
> <https://code.qt.io/cgit/qbs/qbs.git/tree/src/lib/corelib/tools/vsenvironmentdetector.cpp#n243>).
>
> Best
>
> Jochen
>
> *Von: *Qbs <qbs-bounces at qt-project.org> im Auftrag von Heiko Nardmann 
> <heiko.nardmann at itechnical.de>
> *Datum: *Donnerstag, 6. März 2025 um 18:17
> *An: *qbs at qt-project.org <qbs at qt-project.org>
> *Betreff: *[Qbs] MSVC based profile: how SDK detection is working?
>
> Hi together,
>
> I'm currently fighting with getting Qbs working with MSVC 2022. 
> Somehow the probing fails and I wonder whether this has sth to do with 
> the SDK version: that is shown as being undefined when dumping it 
> inside MsvcProbe.qbs.
>
> So ... how do I tell Qbs which Windows SDK version to use? Or how is 
> the detection working wrt. this?
>
> /Kind regards,/
>
>   Heiko
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20250307/a499369d/attachment.htm>


More information about the Qbs mailing list