Is it possible to see which commands are actually executed by Microsoft Visual C++ 2010 Express when it builds a solution/project? I found out that in the Configuration Properties of a solution there is a Command Line window for both the compiler (C/C++) and the linker (Linker) but that does not really show all parameters (e. g. source and object/binary files).
I would like to see the commands in order to write a nmake build script that I can use to compile/link binaries for both the x86 and x64 platform.
You can set the output of a Visual Studio build to be detailed. Go to menu Tools -> Options -> Projects and Solutions -> Build and Run. Change the MSBuild project build output verbosity option, typically from the default Minimal to Normal, Detailed or Diagnostic.
Also take a look at /VERBOSE (Print Progress Messages) to set the linker output more verbose.
For Visual Studio 2010 and 2005
View->Output or Alt+2
Show output from: Build
For the compiler/linker parameters
Project->Project Properties
Configuration Properties -> C/C++ -> Command Line
Configuration Properties -> Linker -> Command Line
Related
I'm building a Windows exe using Bazel (release 4.1.0). I'm building by first opening the "x64 Native Tools Command Prompt For VS 2019" in order to set the environment to use VS 2019 build tools and then use that command prompt to compile via
bazel --bazelrc windows.rc build --verbose_failures -c opt myproject:mytarget
in my windows.rc I added the following lines:
# Enable "Whole program optimization"
build --copt /GL
# Enable Link Time Code Generation
build --linkopt=/LTCG
#embed debug symbols
build --copt /Z7
build --strip=never
and this causes the resulting exe to get significantly bigger. But when I then attach the Visual Studio 2019 Debugger to the process, Visual Studio nevertheless tells me Binary was not built with debug information.
What else do I need to do to be able to attach the debugger and have debugging symbols loaded?
Note: I specifically want to create a release build (-c opt) with all optimizations, but have symbols included (like described here for Visual Studio: https://learn.microsoft.com/en-us/cpp/build/how-to-debug-a-release-build?view=msvc-160)
I have a multiplatform CMake project, and occasionally I have to build it manually for Windows. I generate a buildsystem like this:
cmake -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -A x64 ../path/to/source
Then I open *sln file and press F7 to build. It runs for 40 minutes, and after that I understand that I didn't select proper configuration in the combobox. It's annoying! When command line option was -DCMAKE_BUILD_TYPE=Release, but combobox was set to Debug, build fails after spending a decent time.
Is it possible to generate an MSVS project with build configuration selected from command line?
Note that I'm aware of msbuild command and it's -p:Configuration=xxxxx flag. The question is about cases when for some reason you need to build from Visual Studio's GUI.
Changing the selected configuration for the GUI is not possible with CMake at this moment.
The main reason for this is that this information is stored in the .suo file generated by Visual Studio. CMake itself only generates the project and solution files, while the .suo file will be generated by Visual Studio itself.
Alternatively, use CMake's command line build option for this. After configuring your project and generating the VS .sln file from CMake as usual, simply run:
cmake --build <path_to_build_directory> --config Release
This works independently of the selected generator and is the most reliable way of building CMake projects.
I use CMake to configure and generate makefiles for a Microsoft MPI project that I build and run from Visual Studio 2017. In order to run the project, I need to modify the VS solution configuration settings. Under Configuration Settings->Debugging, I want to specify "Command" and "Command Arguments" from the CMakeLists.txt. I can do this manually but I want to set it up from the CMakeLists.txt. Are there commands to do this?
CMake 3.12 introduced two new target properties for that purpose: VS_DEBUGGER_COMMAND and VS_DEBUGGER_COMMAND_ARGUMENTS. Set these properties in the following way:
set_target_properties(targetName PROPERTIES
VS_DEBUGGER_COMMAND "debug_command"
VS_DEBUGGER_COMMAND_ARGUMENTS "debug_arguments")
for anyone look for a solution on visual studio code with cmake extension, here is a solution:
change program field in launch.json to ${command:cmake.launchTargetPath},
launch.json
ref:
link
Please remind me where is that option. I want to see all events happening during compilation and execution, for example all libraries and their functions that are found in included external libraries.
Tools > Options > Projects and Solutions > Build and Run, change "MSBuild project build output verbosity".
This is just for the build/compilation.
For C++ projects I can do this:
SET CL=/DMYDIRECTIVE
devenv.exe MySolution.sln /rebuild
What is the C# version (visual studio 2008) of this trick?
Go to the Build tab in Project Properties
On the command line, csc /define:MYDIRECTIVE
The following command lists you the options of the C# compiler
csc.exe /?
The respective option is
/define:<symbol list> Define conditional compilation symbol(s) (Short form: /d)
However, for command-line building a C# project you might prefer MSBuild. With MSBuild, it is probably easiest to create a configuration using Visual Studio's Configuration Manager that already defines appropriate conditional compilation symbols. You can then select one of the configurations from the MSBuild command line:
MSBuild MySolution.sln /t:Rebuild /p:Configuration=ReleaseWithMyDirective