views:

421

answers:

4

I'm not using any features of the MSVCRT100.dll (I don't even know if there are new features).

A: 

Unfortunately, yes. You'll need the VC10 runtime for your platform (x86) or (x64) -- keep in mind though the runtime may change, though it is highly unlikely since VStudio has been in it's final phases for a while now.

It is the core runtime library, you can find out more of your dependencies using DependencyWalker (http://www.dependencywalker.com)

Or alternatively, try it :-)

mjsabby
Ok, thank you ... how do I create a project of type dll.
halivingston
Just select "Win32 Project" when you create a new project, and select type "DLL" when it's project type comes along, it's the second window I think.It'll include the boiler plate code you need, DllMain, etc.
mjsabby
got it tank you
halivingston
That's wrong - static linkage is usually also possible. See my post.
Alexander Gessler
This is a wrong answer. It is perfectly possible to link the CRT statically, or even not link it at all.
Nemanja Trifunovic
A: 

You can use VS2010 and still target older versions of the runtime. This can be configured in your project properties, here's an image:

pic from VC++ blog

Obviously you still need the toolset you're targeting installed.
For more info you can look at this VC++ team blog post.

Idan K
+2  A: 

Well, you should be able to statically link it. Your .dll will be way bigger, but would not require msvcrt. This is controlled by Code Generation->Runtime library (choose /MT).

BarsMonster
+1, but "way bigger" is relative. He should check it for himself to see how much the size will increase.
Nemanja Trifunovic
+2  A: 

Most applications use the C/C++ Runtimes. You may be using the runtime in a fashion you don't know of yet ... call fopen() somewhere? Then you use it.

However, as it pointed out by BarsMonster, you can link statically to the runtime. Your binary size grows, but you have no external dependencies. In fact this is the method you would choose if don't want to use installer software to deploy your application.

It's almost certainly the best choice for stuff like external libraries that are not bound to a particular application and could be reused several times. If you release your DLL to somebody in a SDK, i'd recommend providing lib's and dll's for both static and dynamic linkage to the runtime.

Keep in mind, however, that static linkage has one serious disadvantage: heap memory is not shared across DLL boundaries then. A memory block must be freed by the module (DLL) which allocated it i the first place. If you can't fulfil this requirement, do not use static linkage. Deploying with the runtime can't be avoided then.

Alexander Gessler
Runtime library is not required to start a process. It is possible to have a "pure" Win32 API process that does not include CRT at all.
Nemanja Trifunovic
Yes, of course you're right, I mixed up two different things ... made an edit.
Alexander Gessler