Profiling with CMake, C++, and Visual Studio 2012 - visual-c++

I am using CMake 2.8.10.1 to generate project files for Visual Studio 2012 Ultimate (64-bit). The resulting solution contains a library, some tests, and some executables.
I would like to profile some of the applications. When I select "ANALYZE" -> "Start Performance Analysis," I encounter the error message "No launchable projects are available for profiling." How can I profile my solution generated by CMake?

It seems I've found a way to fix it. You need to add win32 configuration under your project. Then profiler will see your project as launchable.
For example, for the release configuration you should add the following
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
under
<ItemGroup Label="ProjectConfigurations">
Using the menu:
Build -> Configuration Manager
Goto row of the project to profile
In the platform column note that it will only have a x64 entry
Use dropdown <New...> and select Win32 for New platform:
-

That's a ridiculous bug in Visual Studio. QMake also suffers from this.
https://connect.microsoft.com/VisualStudio/feedback/details/823467/performance-wizard-doesnt-show-any-projects-to-profile-if-there-is-no-win32-configuration

Related

Configure Visual C++ project to use the 64-bit tool set when building 32-bit executable

I am trying to enable link-time codegen (LTCG) and whole program optimization (WPO) for the build of a large Windows C++ application built with Visual Studio 2017. The 64-bit product builds fine but the codegen step of our 32-bit build runs out of memory.
So, I need to switch the 32-bit builds to use the 64-bit link.exe as described here: How to: Enable a 64-Bit, x64 hosted Visual C++ toolset on the command line
Specifically:
The 32-bit and 64-bit tools generate identical code, but the 64-bit tools support more memory for precompiled header symbols and the Whole Program Optimization (/GL and /LTCG) options. If you run into memory limits when you use the 32-bit tools, try the 64-bit tools.
It describes doing this from a command line build but I need it within the devenv environment. I have searched unsuccessfully for a Solution or Project setting to control using the 64-bit tool set for a 32-bit build.
I suspect I'll need to edit the .vcxproj file directly but am not sure what to add. Can anyone tell me how to setup my 32-bit build this way?
An alternative answer is to use PreferredToolArchitecture in the project.
Using Visual Studio 2019 (v16.1) this can be done in the properties dialog of the project under "Configuration Properties\Advanced\Prefered Build Tool Architecture". Specify x64.
For older versions of Visual Studio, editing the vcxproj is required. This is documented in Walkthrough: Using MSBuild to Create a Visual C++ Project
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
Found my own answer... You do need to hand-edit the .vcxproj file and add this to the PropertyGoup
<UseNativeEnvironment>true</UseNativeEnvironment>
So mine now looks like this:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<UseNativeEnvironment>true</UseNativeEnvironment>
</PropertyGroup>

Create a setup file in Visual Studio 2012

I have a windows form project and I want to create an installation package for this project. How can I create a setup file in Visual Studio 2012 ? My project is without data base.
How to create a Setup package using Visual Studio 2012.NET?
Microsoft released the Visual Studio Installer Project extension in April of this year, the catch is it's for VS2013, not VS2012.
http://blogs.msdn.com/b/visualstudio/archive/2014/04/17/visual-studio-installer-projects-extension.aspx
The 'lite' InstallShield option remains in VS if you need something with more flexibility.
Advanced Installer also has a free version that includes an extension for VS. This is a commercial tool but the extension is included in the free edition as I said, for more advanced features you need to purchase a Professional or higher licenses and edit the project direct from Advanced Installer GUI, not from VS. (but you can still use the project in the VS solution, so you get the MSI built at the end of your build process)
Visual Studio setup projects (vdproj) are not supplied with VS 2012
There are several solutions for you:
You could use InstallShield instead.
If you don't want or
can't use InstallShield for any reason, you could try WiX. This
toolset builds Windows installation packages from XML source code.
If you only use Windows Presentation Foundation (.xbap), Windows Forms (.exe), console application (.exe), or Office solution (.dll) you could look at ClickOnce. To use this you should right click on the project file in the solution explorer and select "Publish" from the pop-up menu.
Alternatively you can use previous version of Visual Studio (2010).

Choose VC++ runtime version of an MFC project in Visual Studio

I created a MFC project with VS2013 and it works fine on my computer. But it won't run on a computer without VC++ Redistribution 2013 installed.
Can I specify a lower VC++ runtime version of an MFC project in Visual Studio?
I think even if it is lower vc++ runtime version, you may face similar problem.
If you can tolerate exe file is larger than before, just change the value of Use of MFC to Use MFC in a Static Library in project property page. By doing so, you don't need to distribute mfc modules related.
Otherwise, you have to distribute relative mfc modules such as mfc100.dll.
This link may help you.
You need to create installation package for your program. As Visual Studio user, you can create an installation with InstallShield Limited Edition. Installation package should contain correct C++ and MFC runtime version for your program.
See also:
InstallShield Limited Edition http://msdn.microsoft.com/en-us/library/dn531020.aspx\
Walkthrough: Deploying Your Program (C++) http://msdn.microsoft.com/en-us/library/bb384837.aspx
Specifically, to add VC++ Runtime: On the Redistributables tab in the editor window, select the Visual C++ 11.0 CRT check box. If you use MFC, check also MFC redistribution.

How to use MSBuild to target v110 platform toolset?

I am developing a command line application that creates a full Visual Studio 11 solution made of a single VC++ project and that tries to compile it in the end using MSBuild.
The problem I am facing is strange.
If I execute my command line program inside Visual Studio 11 it works; if I instead launch it outside the development environment it throws me the error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(511,5): error MSB8008: Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected. [f:\ABC.vcxproj]
The command I am using is the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe f:\snake\W9A30040.vcxproj /property:PlatformToolset=v110;Configuration=Debug /v:quiet
But I have the feeling that PlatformToolset=v110 is ignored and MSBuild use v100 (Visual Studio 2010).
Do you have any suggestions how to tell MSBuild to compile for v110 Platform Toolset?
I ran into the same problem as well with the full release of VS 2012. You can also set the VisualStudioVersion as a property with MSBuild as opposed to dealing with environment variables as mentioned in the accepted answer. For instance:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\myproject.vcxproj /p:VisualStudioVersion=11.0
The environment variables approach I'm sure work just as well, I honestly didn't try that as I was trying to stay away from having to modify the environment variables.
Make sure that the top of your .SLN file looks like this:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
When you double-click on the solution file, it's the # Visual Studio 2012 that controls which version of Visual Studio is loaded (and controls the icon displayed in Windows Explorer).
However, when you run MSBuild, it looks at the Format Version 12.00 part.
Confused?
This is confusing, since Visual Studio 2010 is version 10.0 and Visual Studio 2012 is version 11.0 (not 12.0), and using the version 12.0 solution file format causes MSBuild to (implicitly) set VisualStudioVersion to 11.0.
I found a workaround for this issue; could be a problem of Visual Studio 11 Beta that will be resolved before official release.
Anyway, if you are interestedm just set the environment variable "VisualStudioVersion" equal to "11.0" before calling MSBuild.exe.
In batch files
set VisualStudioVersion=11.0
or in VB.NET
Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
Starting with Visual Studio 2013, MSBuild is now part of Visual Studio, and the correct path should be $(MSBuildToolsPath) (“C:\Program Files (x86)\MSBuild\12.0\Bin”). If you use msbuild.exe from the .Net framework folder (“C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) it will not able to distinguish the vs2012 and vs2013 versions.
Use the menu based options to do this. From VC++2010 Express:
- Right click on the main file of the project (not the solution itself at the very top of the tree).
- Click General.
- Find Platform Toolset on the right side of the dialog, top half.
- Change from v110 to v100.
- Click OK.
----- Done ------
Microsoft provides a batch file to set all the EnvVars
You find it in the Start Menu under "Microsoft Visual Studio 2012/Visual Studio Tools" or in the Visual Studio folder ("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat")

Visual C++ 2008: omp.h not found? /openMP is set

I've enabled openMP using the project settings, but when I do #include I get an error the file doesn't exist. I'm using Visual Studio stadnard edition, not Express... what else is missing? Every page I find simply says to turn it on in project settings and it will work.
omp.h and vcomp.lib is only available in VS Pro editions.
Did you add the directory containing the file omp.h to the list of directory search paths? Go to "tools - options - projects and solutions - VC++ Directories", then "show directories for" "include files". Add the path in here.
The solution for Visual Studio 2008 Express to develop OpenMP on Windows also works with the Standard Edition.
Basically you need to install the Windows SDK for OpenMP to get the libraries and headers. In my case I had to install the patch KB974479 too, but that may not be the case if one enables Microsoft Update for VS2008 (which I forgot to enable for all Microsoft products right after installing Windows).

Resources