all groups > visual c libraries > december 2003 >
You're in the

visual c libraries

group:

Building DLL, please help!!


Building DLL, please help!! Jeoff
12/25/2003 6:54:58 PM
visual c libraries:
Hi,All

I have a question on how to build a universal DLL(Dynamic
Linking Library)or Lib(static library), which could be
used both in Debug and Release verisons. As i know,
edition of the application which invokes the library must
be the same with DLL. The application in Debug only works
with the DLL in Debug, otherwise the Release is the same.

Would you please give me some advice?

Thanks ahead,

Jeoff

Re: Building DLL, please help!! Mihajlo Cvetanovic
12/26/2003 11:15:33 AM
[quoted text, click to view]

It isn't necessary to match apps and dlls but it's a Good Thing To Do.
If it will never happen a situation where one side allocate memory and
the other free it, and if none of the sides relies on memory appart
from what it gets via function arguments then there shouldn't be any
problems (if I'm wrong somebody please correct me).

To put it simply if your dll does malloc/new then it must free/delete.

If it is really necessary to pass buffer management to the other side
then there should be a function from buffer creator's side available
to buffer receiver for buffer deallocation.

In another words if there is a function in your dll:

char* CreateNewBuffer(void);

ther there should be as well:

void DeleteBufferCreatedInThisDll(char*);
Re: Building DLL, please help!! Tony Nassar
1/3/2004 10:39:29 AM
I'm not sure this is correct. If you're using VS 6.0, then there is a
settings for each DLL and EXE called something like "Link statically" or
"Link dynamically", i.e., "link this module statically with the C runtime
library" or "link this module with the stub library, and load the DLL
version of the C runtime library at runtime." If you build all your modules
with the latter, then there will be only one memory manager (and only one
heap) at runtime, and a DLL *does not* have to free what it created.

[quoted text, click to view]

Re: Building DLL, please help!! Mihajlo Cvetanovic
1/4/2004 5:33:12 PM
True, but sometimes a programmer starts playing with compiler/linker
options, and finds out (or worse it doesn't find out) about new "bugs"
never seen before. This is the safe way, or "best programming
practice". Or in biblical terms: "I'm Alfa and Omega, your Constructor
and Destructor!" ;-)

[quoted text, click to view]
AddThis Social Bookmark Button