views:

92

answers:

3

Hello! Is it possible to make my C++ application run on a machine without Microsoft Visual C++ 2008 Redistributable Package by simply including some dlls in the program folder?

I want to make my app as portable as possible and want to avoid forced installation of the runtime, so is it possible?

I don't care about possible future runtime .dll update and other troubles related, I simply want to supply my app with everything that it could possibly need (on every Windows XP+ machine). Did someone face the same problem?

Thank you.

+10  A: 

Actually, you can link with the static runtime libraries and you won't need to redistribute any of the runtime DLLs. Check the documentation or the Visual Studio help for details on how to link with the static runtime libraries.

Jim Mischel
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/ab187afb-3af0-44ba-a03c-dde9e5208a1a/
DyP
Static linking is the best way to go for maximum portability
the_mandrill
Be careful, better know what you're doing if you have your own DLLs.
Hans Passant
+4  A: 

Yes, you can, but it's a little tricky to get all the dependencies right. It's not quite as simple as just "drop msvcrt.dll in to this folder and go." I've done what you're trying to do. It's not worth it.

For reference, see here

If you want to balance keeping your code small and reducing client-side dependancies, you may want to consider statically linking to the VC runtime.

John Dibling
But doesn't it say (in steps for `private assemblies`), that I simply have to copy VC90 runtime dlls and that's all?
HardCoder1986
I second the comment: "it's not worth it". I've gone through the process as well, and it is a big pain.
Daryl Hanson
@Daryl Could you describe the steps please? Or at least what else do I have to do besides dll copying?
HardCoder1986
@HardCoder1986: I don't recall if I actually succeeded, and it's been quite a while since I attempted it. I'm sorry, but I don't have any notes written of what I went through. In the end I think I installed the redistributable runtime. Since then I've switched to using static libs. Rather rather ironic since it seems MS's intentions were to reduce DLL hell and actually made it worse (at least from this perspective). Going the static route has the additional benefit of being able to run debug builds on systems without the redist installed.
Daryl Hanson
A: 

Jim Mischel answer is good(+1), but sometime you just need to have dll but still want to provide a unique exe in the end.

Then, tools like UPX comes to rescue...

Klaim