DLL Hell(p)

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?
 
J

Jack Klein

Hi, I'm having some problems with DLLs (using C++, so it's on topic). Can
^^^^^^^^^^^^^^^^^^^^^^^^^^^
No, it's not. The language does not define DLLs, static or dynamic
libraries, or interactions that arise out of that choice.
someone help me?

Yes, people in a group that supports your particular compiler/os
combination, or a Windows programming group like
 
G

GTO

Is there a way to work around this that doesn't completely suck?

Yes. Switch to Linux! ;-)
 
A

Al A. Palooza

Facetious, but possibly more helpful than the other responses.

Brings up a question: using unix dynamic libraries the same problem would
arise, so how would you recommend working around it?
 
R

Rolf Magnus

Al said:
Facetious, but possibly more helpful than the other responses.

No. The other responses told you where to ask your question.
Brings up a question: using unix dynamic libraries the same problem would
arise, so how would you recommend working around it?

That should be asked in comp.unix.programmer.
 
A

Al A. Palooza

God help me, is there a comp.os.pedantic?

That's four - count 'em, four! - responses, from people who could probably
offer some valuable advice, but instead just say "take the question
elsewhere".

I took the question elsewhere, to three different newsgroups. Not a single
response there. Guess the only reason people reply is to tell you you're
off-topic. (Or to make jokes, then tell you responses to the jokes are
off-topic).

Usenet is hilarious.
 
R

Raymond Martineau

That's four - count 'em, four! - responses, from people who could probably
offer some valuable advice,

No. A large number of people on this newsgroup do not program on Microsoft
Windows, let alone have the VC++ compiler. Even if they did know how to
program with that operating system, they would not have enough information
to figure out why the singleton class was crashing. (i.e. they don't know
which memory manager you were using.)
 
O

Owen Jacobson

Facetious, but possibly more helpful than the other responses.

Brings up a question: using unix dynamic libraries the same problem would
arise, so how would you recommend working around it?

Possibly not. As I understand it, under most unices shared objects
(dynamic libraries) are placed in the loading process's address space,
rather than having their own address space, which is the source of the
problem you're having. BICBW.

F'ups set.

Owen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top