A
Al A. Palooza
Hi, I'm having some problems with DLLs (using C++, so it's on topic). Can
someone help me?
The problem is this: I have a common-functionality DLL, and an EXE. The EXE
uses the DLL. But both the DLL and the EXE use a basic static library which
implements a memory manager.
The memory manager class has a singleton instance, s_pInstance. This is a
static member of the memory manager class. To access the memory manager the
user calls MemMgr::Get (a static function).
Seems pretty straightforward. But because both the DLL and the EXE use the
LIB, both need to have copies linked to them at build time. This results in
two copies of the same library in memory. So when one calls MemMgr::Get it
gets a different pointer from the other, resulting in crashes (I only set
the pointer once).
Is there a way to work around this that doesn't completely suck? The only
way I can think of is to pass a common memory manager pointer from one of
the clients to the other, but this breaks the anonymity and extenstion I was
trying to achieve - plus just hides the fact that both are statically linked
to a library that I only need one instance of.
The other solution would be to make the static library a DLL but since it
doesn't _need_ to be dynamically loaded it seems kind of a waste.
Any ideas?
someone help me?
The problem is this: I have a common-functionality DLL, and an EXE. The EXE
uses the DLL. But both the DLL and the EXE use a basic static library which
implements a memory manager.
The memory manager class has a singleton instance, s_pInstance. This is a
static member of the memory manager class. To access the memory manager the
user calls MemMgr::Get (a static function).
Seems pretty straightforward. But because both the DLL and the EXE use the
LIB, both need to have copies linked to them at build time. This results in
two copies of the same library in memory. So when one calls MemMgr::Get it
gets a different pointer from the other, resulting in crashes (I only set
the pointer once).
Is there a way to work around this that doesn't completely suck? The only
way I can think of is to pass a common memory manager pointer from one of
the clients to the other, but this breaks the anonymity and extenstion I was
trying to achieve - plus just hides the fact that both are statically linked
to a library that I only need one instance of.
The other solution would be to make the static library a DLL but since it
doesn't _need_ to be dynamically loaded it seems kind of a waste.
Any ideas?