Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing the whole command used by Visual Studio to compile a file

When we compile a C/C++ project in Visual Studio, the output window just prints the name of the file being compiled. How do we print the whole command? I.e., all the include directories, flags, etc. being used in compiling that file?

I know there is an option when we right click on a file name, PropertiesCommand line, which shows the command to be used while building, but I want it to get printed on the output window.

like image 223
Rajat Avatar asked Nov 04 '22 18:11

Rajat


People also ask

How do you compile in Visual Studio?

Open Visual Studio. Go to File > Open > Folder… and open the MuseScore checkout folder. Visual Studio will automatically begin to generate a CMake cache, which will include the Visual Studio solution and project files.

What is Visual Studio compiler command line?

Command-line tools To build a C/C++ project at a command prompt, Visual Studio provides these command-line tools: CL. Use the compiler (cl.exe) to compile and link source code files into apps, libraries, and DLLs. Link. Use the linker (link.exe) to link compiled object files and libraries into apps and DLLs.

How do I get the build command in Visual Studio?

To compile source files from within the Visual Studio IDE, choose the Build command from the Build menu.

How do I compile C++ code in Windows?

Create a Visual C++ source file and compile it on the command line. In the developer command prompt window, enter md c:\hello to create a directory, and then enter cd c:\hello to change to that directory. This directory is where both your source file and the compiled program get created. Enter notepad hello.


1 Answers

You can see command line switches in BuildLog.htm file produced by Visual Studio. Use Ctrl+Click in the Output window link to see this file after building a project.

Also, reading this file, we can see that printing full command line in Output window will not help:

Creating temporary file "c:\tmp\test\Debug\RSP00000125403116.rsp" with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\test.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TP .\test.cpp
]
Creating command line "cl.exe @c:\tmp\test\Debug\RSP00000125403116.rsp /nologo /errorReport:prompt"

So, Visual Studio creates temporary file with command line switches, and command line contains this file name.

Update for new Visual Studio versions. Tools - Options - Project and Solutions - Build and Run. MSBuild project build output verbosity. Select Detailed or Diagnostic to see more information in the build log (Output window).

like image 101
Alex F Avatar answered Nov 12 '22 17:11

Alex F