C-Run-time library static vs DLL vs both!

I have now settled down to having my language-support resource DLLs carrying 
the minimum amount of code (other than none):

One cpp file:

============
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
      ) {   return TRUE;  }
============

These "language resource DLLs" go with a project with lots of big DLLs some 
of which are MFC extension DLLs and most of which link to the C-runtime DLL.

If I imply in the language resource project that it might use the CRT DLL 
(with C++ code generation/Runtime library /MTD) then it generates an 
embedded manifest with a dependency on the CRT DLL.

I don't want that.   If I use C++ code generation/Runtime library /MT 
(which sort of implies static linking to the C-run-time library) then it 
generates a preferable manifest.

Questions:
1. Does the above code actually need the C-Runtime library?
2. If so, can I link some modules to it statically and others to the DLL? 
[It is not something I'd care to try with MFC but I'm unsure about the CRT.]

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

0
dave9996 (486)
6/11/2008 7:27:01 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
811 Views

Similar Articles

[PageSpeed] 43

Hi Dave,


"David Webber" <dave@musical-dot-demon-dot-co.uk> ha scritto nel messaggio 
news:OEtA$m$yIHA.1236@TK2MSFTNGP02.phx.gbl...

> One cpp file:
>
> ============
> #define WIN32_LEAN_AND_MEAN
> #include <windows.h>
>
> BOOL APIENTRY DllMain( HANDLE hModule,
>                       DWORD  ul_reason_for_call,
>                       LPVOID lpReserved
>      ) {   return TRUE;  }
> ============

> Questions:
> 1. Does the above code actually need the C-Runtime library?

It seems that it is not calling any C-runtime function (printf, atof....) 
.... however, I don't know if the linker needs to add some prologue-epilogue 
code to that, behind the scenes...


> 2. If so, can I link some modules to it statically and others to the DLL?

I'm not sure if I understood the question well...
Does this question mean:
"Can I link some modules to CRT statically, and other modules to CRT DLL 
(dynamically) ?"

I think the question is yes, if you pay attention to the fact that *any* 
heap allocation that you do in a module which is statically-linked to CRT, 
is freed by the *same* module (because I think that static-linked CRT heap 
is different from dynamically-linked CRT heap).

Giovanni



0
6/12/2008 10:19:46 AM
"David Webber" <dave@musical-dot-demon-dot-co.uk> wrote in
news:OEtA$m$yIHA.1236@TK2MSFTNGP02.phx.gbl: 
> Questions:
> 1. Does the above code actually need the C-Runtime library?

No. It doesn't need the code either.

> 2. If so, can I link some modules to it statically and others to the
> DLL? [It is not something I'd care to try with MFC but I'm unsure
> about the CRT.] 

See above.

The project file for my resource DLL has no code. The easiest way to set 
things up is to use the project wizard and select the resource dll target. 
You can then easily copy that vcproj file to other targets.

If I use depencyency walker to look at my dll, there are no dependencies. 
It truly is a resource-only dll.

Dave Connet
0
stuff7507 (45)
6/12/2008 2:21:30 PM
"David Connet" <stuff@agilityrecordbook.com> wrote in message 
news:Kha4k.7591$uE5.533@flpi144.ffdc.sbc.com...

>> Questions:
>> 1. Does the above code actually need the C-Runtime library?
>
> No. It doesn't need the code either.
> The project file for my resource DLL has no code. The easiest way to set
> things up is to use the project wizard and select the resource dll target.
> You can then easily copy that vcproj file to other targets.

That sounds like a good trick.   Maybe I'll give it one last try.   Your 
comment on the other thread about loading with plain old ::LoadLibrary() 
(instead of ::LoadLibraryEx() and loading as a data file) is an option I had 
overlooked - thanks.

> If I use depencyency walker to look at my dll, there are no dependencies.
> It truly is a resource-only dll.

Yes I found that as well.

I'll fish out my proper resource only builds and see if LoadLibrary does the 
trick for me - thanks.

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm 

0
dave9996 (486)
6/12/2008 2:57:03 PM
David Webber wrote:
> I have now settled down to having my language-support resource DLLs 
> carrying the minimum amount of code (other than none):
> 
> One cpp file:
> 
> ============
> #define WIN32_LEAN_AND_MEAN
> #include <windows.h>
> 
> BOOL APIENTRY DllMain( HANDLE hModule,
>                       DWORD  ul_reason_for_call,
>                       LPVOID lpReserved
>      ) {   return TRUE;  }
> ============
> 
> These "language resource DLLs" go with a project with lots of big DLLs 
> some of which are MFC extension DLLs and most of which link to the 
> C-runtime DLL.
> 
> If I imply in the language resource project that it might use the CRT 
> DLL (with C++ code generation/Runtime library /MTD) then it generates an 
> embedded manifest with a dependency on the CRT DLL.
> 
> I don't want that.   If I use C++ code generation/Runtime library /MT 
> (which sort of implies static linking to the C-run-time library) then it 
> generates a preferable manifest.
> 
> Questions:
> 1. Does the above code actually need the C-Runtime library?
> 2. If so, can I link some modules to it statically and others to the 
> DLL? [It is not something I'd care to try with MFC but I'm unsure about 
> the CRT.]
> 
> Dave
Hi,

when in doubt on whether my app was linked to a library, I use the 
Dependency Walker. This app, distributed with the SDK (and VC++ IIRC) 
shows me all the libraries my app is linked to, including the entry 
points (the functions that uses) and such. You ought to look at this 
app, if only to be sure.

Regards.
0
6/12/2008 3:18:18 PM
Your suggestion to use true resource only DLLs but load them with 
::LoadLibrary()   ( and forget about ::LoadLibraryEx() with 
LOAD_LIBRARY_AS_DATAFILE )  is *the* answer!

My Panamanian friend is now happily testing the program in Spanish again!

Thank you!  (And to all the others who helped.)

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm 

0
dave9996 (486)
6/13/2008 7:45:12 AM
Reply:

Similar Artilces: