0

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.

2
  • I just tested a C++ project and the command line is displayed on detailed verbosity (-v:d). Commented Jul 4 at 22:56
  • In VS 2022 I created a new C++ console project, set Output Verbosity to "Detailed", ran "Clean" and "Build". The output for Target ClCompile includes 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 Commented Jul 5 at 0:54

3 Answers 3

1

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

4
  • thank you this worked! Do you know if there is a way to search in the output window? ctrl+f doesn't seems to work
    – roi_saumon
    Commented Jul 8 at 9:19
  • Click in the output window to ensure it has focus, then use Ctrl+f. Commented Jul 8 at 11:14
  • okay, this didn't work for me unitil I did Tools -> Option -> Environment -> Keyboard -> Reset
    – roi_saumon
    Commented Jul 8 at 14:18
  • The "Edit -> Find and Replace -> Quick Find" menu should work even when the shortcut key binding is not global Commented Jul 8 at 23:27
1

but I cannot see it in the output window, regardless of the verbosity.

Did you set build output verbosity to Diagnostic from here?

Menu Tools → Options → Projects and Solutions → Build and Run → MSBuild project build output verbosity: Diagnostic

If yes, but still cannot see it, please try to set this compiler option : Suppress Startup Banner. 1.Open the project's Property Pages dialog box.

2.Select the Configuration Properties > C/C++ > General property page.

3.Modify the Suppress Startup Banner property to No.

Based on my test, the cl command line(s) will be shown in the output window. enter image description here

Docs referred:

https://learn.microsoft.com/en-us/cpp/build/reference/nologo-suppress-startup-banner-c-cpp?view=msvc-170

Hope it can help you.

0

The way I have done it when I needed to see the exact parameters passed to a routine being called by an IDE was to make a simple exe file shim that reflects its entire command line to stderr and very carefully substitute it temporarily for the original cl.exe. On the Intel compiler it turns out you can just add "-v" to the command line. But no such luck with MS. I described my method in this question but didn't get a better answer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.