Use Visual Studio 2012 and Compile with Older Platform Toolset

Use Visual Studio 2012 and compile with older platform toolset?

According to this page on MSDN, you need to have the corresponding version of Visual Studio (2008 or 2010), or the relevant Windows SDK for the "Platform Toolset" drop down to list those versions:

To change the target platform toolset, you must have the associated version of Visual Studio or the Windows Platform SDK installed.

You also seem to be a little bit confused between "Platform Toolset", which controls which compiler/linker/etc. is used to build your application, and "Visual C++ Redistributable", which is needed to run your application. You can't install a "Platform Toolset" on a user's PC, and nor will you make one available by installing a particular "Visual C++ Redistributable" on your development PC.

Also, as far as I know, the Visual C++ Redistributable doesn't include the MFC runtimes. They're available as a separate MSI merge module (MSM).

How to build with v90 platform toolset in VS2012 without VS2008, using Windows SDK?

It is possible, but apparently requires some maneuvering and will not support building MFC applications. The following assumes that VS2012 update 4 is installed, but neither VS2010 nor VS2008 are installed.

  1. Download the x86 DVD of SDK 7.0 SP1 (GRMSDK_EN_DVD.iso). Mount the ISO or extract its contents, and manually install the MSI files from the following folders under the Setup folder:

    • WinSDK (this may fail, it's ok)
    • WinSDKBuild
    • WinSDKInterop
    • WinSDKTools
    • WinSDKWin32Tools
    • vc_stdx86
    • vc_stdamd64
    • winsdk_intellidocs
    • WinSDKIntellisenceRefAssys
    • WinSDKNetFxTools

     

  2. Download the x86 DVD of SDK 7.1 (GRMSDK_EN_DVD.iso). Mount the ISO or extract its contents, and manually install the MSI files from the same folders listed above (except winsdk_intellidocs, which doesn't exist).

  3. Go to C:\Program Files (x86)\Microsoft Visual Studio 9.0. Copy the following files from Common7\IDE to VC\bin:

    • msobj80.dll
    • mspdb80.dll
    • mspdbcore.dll
    • mspdbsrv.exe

Now you should be able to choose the v90 platform toolset in Visual Studio 2012 and build with it.

Explanations (and sources):

  • Individual MSI installation is based on the second workaround from this connect report.
  • The requirement for both 7.0 and 7.1 is based on this question (both VS2010 and VS2008 are required to use v90 in VS2012!). SDK 7.1 is not needed if you have VS2010.
  • DLL/EXE copying requirement is based on yet another question. If you do not copy them, you will see error MSB6006: "CL.exe" exited with code -1073741515.

Can VC++ programs built with platform toolset Visual Studio 2012 (v110) run on Windows Server 2003/2008?

I have given this a test and can answer that yes they will run provided that the VC++11 re-distributable DLLs are available on the path i.e. msvcp110.dll, msvcr110.dll etc..

Visual Studio wants to build with wrong platform toolset

Under "C/C++", there was a lib in "Additional include directories". I did not use this lib, but it was referenced. I removed this lib.

I also deleted all "studio 2010" entries in the registry.

Visual Studio 2012 C++ platform toolsets missing

The v90 platform toolset is part of VS 2010, so you must install both VS 2008 and VS 2010.

Using Visual Studio 2012 IDE, but compile with Visual Studio 2008

Yes it is possible as can be found on the Visual Studio site. However, I believe it will only give you options of the versions you have currently installed on the machine in question.

Here are the steps as laid out in the link, provided here to ensure the information link does not get broken:

(authored and published by Microsoft)

To change the target Framework

  1. In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Unload project. This unloads the project (.vcxproj) file for your project.
    Note: A C++ project cannot be loaded while the project file is being modified in Visual Studio. However, you can use another editor such as Notepad to modify the project file while the project is loaded in Visual Studio. Visual Studio will detect that the project file has changed and prompt you to reload the project.

  2. On the menu bar, select File, Open, File. In the Open File dialog box, navigate to your project folder, and then open the project (.vcxproj) file.

  3. In the project file, locate the entry for the target Framework version. For example, if your project is designed to use the .NET Framework 4.5, locate v4.5 in the element of the element. If the element isn't present, your project doesn't use the .NET Framework and no change is required.

  4. Change the value to the Framework version you want.

  5. Save the changes and close the editor.

  6. In Solution Explorer, open the shortcut menu for your project and then choose Reload Project.

  7. In Solution Explorer, open the shortcut menu for your project and then choose Properties. In the Property Pages dialog box, in the left pane, expand Common Properties and then select Framework and References. Verify that Targeted framework shows the new Framework version.

To change the project toolset

  1. In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Properties.

  2. In the Property Pages dialog box, open the Configuration drop-down list and then select All Configurations.

  3. In the left pane of the dialog box, expand Configuration Properties and then select General.

  4. In the right pane, select Platform Toolset and then select the toolset you want from the drop-down list. For example, if you want to compile with the Visual Studio 2010 toolset, select Visual Studio 2010 (v100).

  5. Choose the OK button.

Visual Studio 2012 using platform toolset v100. Cannot open source file atlbase.h

  1. Download and install WDK 7.1 (microsoft.com/en-us/download/confirmation.aspx?id=11800)
  2. Create an environment variable which points to the installation directory, I called mine WINDDK
  3. Go to project Properties -> VC++ Directories
  4. Add $(WINDDK)\inc\atl71 to Include Directories
  5. Add $(WINDDK)\lib\ATL\i386 to Library Directories (this is for 32 bit)
  6. Go to project Properties -> Linker -> Input
  7. Add atl.lib to Additional Dependencies

These steps have solved my problem

Is it possible to use the VC++ 6 compiler in Visual Studio 2012?

The answer is definitely maybe. It seems quite possible, but I could not get a copy of VC 6 so I was unable to verify it. What I was able to do was to get VS 2012 to use VC 7 (VS 2002) to compile a project.

Update: The answer is definitely yes. The OP indicates in the comments that he was able to get VC 6 working by using this solution.

Configuration

The way I did this was to install the following (in order of install):

Windows 7, SP1, 32 Bit

I chose Windows 7 because it is the earliest version of Windows that will support VS 2012. I used a 32 Bit version because VS 2002 (VC7) would not install on an x64 machine.

Visual Studio 2002, SP1

As I mentioned, I could not get VC6. It was no where to be found on Microsoft's site. Bruce's comment under this question provides this helpful insight:

Visual C++ 6.0 isn't available (including via MSDN) from Microsoft because it included the Microsoft JVM. See this link for details. – BruceCran

After seeing the above, I figured that installing VS 2002 (VC 7) was the next best thing.

Obviously, this is where you would install VC 6, if you have a copy1.

1I should note, for anyone that is interested, that VC 6 is available on Ebay. If I were being paid in actual currency instead of points I would have gone the extra mile and gotten a copy of VC 6 to test.

Visual Studio 2010, SP1

The only reason for this is that it is a requirement for Daffodil. More on Daffodil below.

Visual Studio 2012, Update 2

This is a requirement from the original question.

Daffodil

This is a set of configuration files that allows VS 2010 and VS 2012 to target older VC compilers.

Currently, these are the supported VC compiler versions:

  • VC 8 (Visual Studio 2005)
  • VC 7.1 (Visual Studio 2003)
  • VC 7 (Visual Studio 2002)
  • VC 6 (Visual Studio 6)

I should note that Daffodil does not officially support VS 2012 as an IDE, but it does seem to work. From the Daffodil site:

Daffodil works fine in VS 2012 and later versions2 as long as VS 2010 is also installed.

2 There appears to be a debugging problem when using VS 2013 and VS 2015, as noted here:

Debugging information does not match, when using v60 platform toolset inside Visual Studio 2013

Testing

To test the above I created a new C++ Win 32 console project in Visual Studio 2012. I then removed all header and cpp files from the project - these have things that are VS 2012 specific, so were not needed. I then added a simple "hello world" file that I could use to test:

#include <iostream.h>

void main()
{
cout << "Hello World!" << endl;
}

Using the project as is (targeting VS 2012), I tried to build it and it failed.

Next, I right-clicked the project and selected properties. I selected Configuration Properties on the left side of the dialog, and then under Platform Toolset, on the right, I selected v70. You will note that there is also an option for v60:

Test Project Properties

I then saved the change to the project and did a build. It built an exe successfully. Just to verify that VC 7 was being used, I launched Process Monitor during the compile:

Process Monitor during Compile

As you can see cl.exe, the compiler, is being called from the VC 7 directory.

Final Thoughts

The original question involves compiling an existing VC 6 project. Just a couple of notes on this.

My guess is that for retargeting to work, that you will have to create a new empty project in VS 2012, and then add in all of the existing source files. The reason for doing this is that obviously the project format is different between the two versions of Visual Studio.

As I mentioned, I tested using VC 7 instead of 6. I suppose the last step is for the OP to try all of this using VC 6. Hopefully it all works.

Links

  • Daffodil at CodePlex
  • C++ Native Multi-Targeting for VS 2010 at the C++ Team Blog
  • VS Android - Configuration for targeting Android using VS 2010
  • VS-Tool - Configurations for targeting various frameworks: Clang, EmScripten, MinGW, NACL, Python


Related Topics



Leave a reply



Submit