visual-studiobuildmsbuildvisual-studio-2022cl.exe

Getting exact cl.exe call when building a visual studio project or solution


When building a visual studio project or solution, how can I get the actual call to cl.exe that is executed? For instance, I would like to see something like

cl.exe /c /I"C:\Path\to\Include" /Fo"Release\main.obj" /EHsc main.cpp

I would like to know the exact arguments that are passed to cl.exe but I cannot see it in the output window, regardless of the verbosity.


Solution

  • I couldn't replicate the issue in Visual Studio 2022 with MSVC v143.

    In Visual Studio 2022 I created a new C++ console app project via the template.

    C++ Console App

    Steps to follow:

    1. Build the solution so that the Output window shows "Build" output.
    2. Set the Output Verbosity to "Detailed".
    3. Run "Clean Solution" and then "Build Solution" (or "Rebuild Solution" but the output will be longer.)
    4. In the Output window search for "ClCompile" as a whole word. (ClCompile is the name of a target in the MSBuild.)

    I have the following output where the first line for Target ClCompile is the compiler command line:

    1>Target ClCompile:
    1>  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permissive- /Fo"CppConso.d37a0e87\x64\Debug\\" /Fd"CppConso.d37a0e87\x64\Debug\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt CppConsoleApplication1.cpp
    1>  CppConsoleApplication1.cpp
    

    output window