How to Use Visual Studio 2010's C++ Compiler with Visual Studio 2008's C++ Runtime Library

Can I use Visual Studio 2010's C++ compiler with Visual Studio 2008's C++ Runtime Library?

Suma's solution looked pretty promising, but it doesn't work: the __imp__*@4 symbols need to be pointers to functions, rather than the functions themselves. Unfortunately, I don't know how to make Visual C++ spit out a pointer with that kind of name generation... (well, __declspec(naked) combined with __stdcall does the trick, but then I don't know how to emit a pointer).

If using an assembler at build-time is OK, the solution is pretty trivial - assemble the following code with FASM and link against the produced object file, and presto - no EncodePointer/DecodePointer references in the exe:

use32
format ms coff

section ".data" data
public __imp__DecodePointer@4
__imp__DecodePointer@4 dd dummy

public __imp__EncodePointer@4
__imp__EncodePointer@4 dd dummy

section ".text" code
dummy:
mov eax, [esp+4]
retn 4

How can I build VS 2010's C Runtime Library?

Here's an MSDN link. It looks like you have to do it yourself in VS2010.

You can use the following compiler and linker options to rebuild the MFC, CRT, and ATL libraries. Starting in Visual C++ 2010, scripts for rebuilding these libraries are no longer shipped.

Can I use build against the 2008 VS Runtime with VS 2010 and no copy of VS 2008?

This MSDN article says that although you can change the platform toolset in the IDE you still need to have the VS2008 binaries installed.

I know you said installing 2008 was not an option but perhaps you can still find the free versions in an old SDK or even the Express version on the Microsoft website.

Using static library from Visual Studio 2008 with Visual Studio 2010

If getting a VC2010 version of the library is out of the question, then you will need to build a DLL using VS2008 that offers the functionality in the VS2008 static library.

You will probably not be able to use C++ linkage to this DLL and certainly will not be able to pass std::string directly between the DLL and your main application. This is because the memory layout/interface is different and you will end up with ODR violations and crashes etc (that's if you can even compile/link it that way without tons of errors).

So, you'll need to craft a C style API that the DLL exposes for use by your main VS2010 application. Strings will need to be passed as c-style const char* or const wchar_t* strings, or some other struct/opaque pointer.

If you can build the DLL in such a way that it is statically linked to the VS2008 runtime then it will ease deployment, otherwise you will need to distribute both the VS2008 and VS2010 runtime with your application installer in whatever manner you choose.

VS2010 Setup Project with C++ 2008 Redistributables?

In order to add C++ 2008 redistributables as prerequisites in VS 2010, I found the following steps to be effective:

  1. Determine the product key for the redistributable. There is a good list here: http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx
  2. Add the installation executable and corresponding xml files to the bootstrapper directory (C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages), as explained here: http://insomniacgeek.com/clickonce-4-0-package-for-the-c-2008-sp1-redist-atl-security-update/
  3. Restart VS, and check the prerequisites list for the setup project. All should now be present.

Also, as an aside, I discovered that unless you take the steps outlined in this question: Visual C++ 2010 Runtime Libraries prerequisite keeps popping up on a VS 2010 created installer your C++ 2010 redistributables will always try to install, even if they are already present.

Building C++ CLR app for Platform Toolset v90 in VS2010 requires Visual Studio 2008

Part of the problem is that VS2010 redid how compiling in c++ (cli or not) works. It now uses the MSBuild structure but I believe what you are trying to do will need the VCBuild framework that is not in 2010.

You may be able to get away with using the Visual Studio 2008 express to build. If not you should only need the c++ portion of VS2008.

Do you need to use the vc90 target though? I build my c++/cli (still new myself) with the vc10 target and it builds fine. (however i am targeting the 4.0 framework referencing some 2.0 portions)

Issue using Visual Studio 2010 compiled C++ DLL in Windows 2000

Visual Studio 2010 cannot build binaries that run on Windows 2000. It's actually even worse than that, they won't run on Windows XP RTM or Windows XP Service Pack 1 either. This is because VS2010's C runtime library requires the EncodePointer API which is not available until SP2.

It appears you're stuck building with installing VS2008 if you want to support earlier versions of Windows. You can either move your entire project to Visual Studio 2008 or you can target the vc90 (Visual Studio 2008) toolset from within your Visual Studio 2010 projects. For more details on the latter method, see this anwser to my related question here.

How to Enforce C++ compiler to use specific CRT version?

I whole heartily join the recommendation not to manually change the CRT version you link against. If however, for some reason (which I cannot imagine) this is the right course of action for you, the way to do so is change the manifest for your project.

First make sure a manifest is not generated on every build (on VS2005: Configuration properties/Linker/Manifest file/Generate manifest), as it would overwrite your manual changes. Also make sure there that isolation is enabled.
Next, locate the manifest file - should be at the $(IntDir) (e.g., Debug). You should see a section similar to -

  <dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>

(For debug builds, of course). You need to edit the version and publicKeyToken attributes of the CRT element.
You can inspect the files at your local WINDOWS\WinSxS folder to see the versions available. Check here how to extract the publicKeyToken once you find the version you want. (Although I'd first try and look directly into manifests of other projects, linking against your desired CRT version).

If you do go there, expect some rough water. You may have some luck if your application is a console app that does not link against other Side-by-Side components (MFC, OpenMP, etc.). If your application is non-trivial, I'd be surprised if there aren't some intricate version dependencies amont the SxS components.

(edit) You'd also need to distribute with your application the specific CRT you're using. Here's someone who did that.



Related Topics



Leave a reply



Submit