1

This page has instructions how to deploy a local copy of VC++ 2008 libraries with your app, to avoid having to install 3rd-party vcredist. This is useful to me because it would let me send a zipped folder to users they can run without having to use an installer, which is disliked.

But, it doesn't work for me. My app doesn't use MFC, just Win32 and is otherwise standard C++. I have app/MyApp.exe and that's it... which files should I be copying from %PROGDIR%\Microsoft Visual Studio 9.0\VC\Redist\x86 and exactly where should they go?

I am testing this on an XP-Mode Virtual PC and when I am trying to follow the instructions in the page, copying files across makes no change to getting the "The application failed to initialize" error. Is there some step I am missing?

I had a look at my manifest and it seems as expected only CRT is used: http://pastebin.com/BD4NZMC2

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589

1 Answers1

0

The easiest way to workaround the DLL-hell is recompiling your application with /MT compiler flag (instead of default /MD). This will link the C runtime libs statically. If this is a standalone exe, this will always work.

If not (i.e you have your own DLLs), you have to take care that you allocate and release memory in the same module - that is, if you malloc() a piece of memory in executable and free() the same pointer in DLL, it will crash - as both executable and DLL will get their own heaps, and attempting a free() on mismatched heap won't work.

Vladislav Vaintroub
  • 5,308
  • 25
  • 31
  • There are a whole bunch of other libraries statically linked to my app; these are all built using /MD and I get linker errors - I'd have to create new build configs for all of them to make them build with /MT. Is that necessary? – Mr. Boy May 18 '11 at 09:59
  • Yep, /MT and /MD compiled objects cannot be mixed. linker dislikes it. – Vladislav Vaintroub May 18 '11 at 10:06
  • I got this technique working, avoiding the need for distributing assemblies, but if anyone knows how to make it work anyway I'd like to know. If nobody bites, this answer can get the points! – Mr. Boy May 19 '11 at 08:52