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, Properties → Command line, which shows the command to be used while building, but I want it to get printed on the output window.
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.
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.
To compile source files from within the Visual Studio IDE, choose the Build command from the Build menu.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With