Just Let It Flow

October 21, 2010

Visual Studio Goes Back to the Future

Filed under: Windows — adeyblue @ 3:26 am

Visual Studio: 2010 compiler and C++0x in the 2008 IDE

Whether it’s because the conventions of the software have changed, they don’t want to learn a new organisation or because they don’t perceive it as something they need, for whatever reason sometimes new software and people just don’t mix. I’m not one of those people usually. But for some reason, the VS 2010 IDE didn’t agree with me. Being primarily a C++ dev though, I wanted to take advantage of and get to grips with the C++0x improvements without having to always use the command line to do so. As Visual Studio components can run independently of the IDE, I thought integrating them into a different one shouldn’t be too hard, and whaddaya know it really isn’t.

Step 1:

Install 2010

If you don’t have a proper copy of VS2010 handy, you can download a trial here. If you don’t plan on keeping VS2010 installed, set aside about 2 hours to remove the 20 or so individual packages it will add but not remove when you come to uninstall it. You nay not need to go through that if you can figure out which files in which cabs on the ISO will make full VS10\Common7 and VS10\VC folders. Unfortunately, I don’t. So for this instruction you’re stuck with the install.

When that’s done, go into the install directory (default is C:\Program Files (x86)\Microsoft Visual Studio 10.0\) and copy the VC and Common7 folders to a different location (henceforth referred to as %VS10%).

Step 2:

Changing Compilers

After copying, changing the compiler is as simple as adding two paths to the VC directories list. In the 2008 IDE navigate to Tools->Options->Projects and Solutions->VC Directories and add the %VS10%\VC\bin and %VS10%\Common7\IDE directories to the top, like below:

The executable paths

The executable paths

If the installer installed the amd64 or ia64 cross compilers you can do the same for those platforms by selecting them from the Platform list box.

Step 3:

Headers and Libs

You have two choices when it comes to headers and libs, remove all traces of 2008’s files or use them side-by-side. The latter option comes with a slight problem, how to differentiate between each versions headers? Adding each versions VC\include directory seperately means that only headers from the version that comes first will be selected with no way (short of giving the full path) to reference the others.

Moving one include directory to be a subdirectory of the other will work, unless you also use the VS provided command prompt for compiling which ends up complaining vociferously about missing headers. As I do use the command prompt sometimes, the third way I chose was to leave each directory where it was and create a recursive symbolic link in %VS10%\VC\Include called vc2010:

Creating a symbolic link to self

Creating a symbolic link to self

VC2010 headers as a last resort...

VC2010 headers as a last resort

... same with libs

Same with libs

I think this config allows the best of both worlds. With the header directories set up so that 2008 comes before 2010 it’s easy to pick and choose which versions headers you want #include <string> = 2008, #include <vc2010/string> = 2010.

That’s it, you’re now all set to go forth and 0x-ify your code with move constructors and rvalue-references. Happy coding.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress