public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Dynamic loader and virtual functions
@ 2002-08-17  5:28 Chris Hennes
  2002-08-17  5:53 ` bjorn rohde jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Hennes @ 2002-08-17  5:28 UTC (permalink / raw)
  To: gcc-help

I have a C++ application that loads plugins using dlopen and dlsym. To 
do this, each plugin has an extern "C" function called LoadPlugin. Up 
until now, this has worked fine. Now, I am developing a new plugin. The 
first few tests worked fine - dlsym found LoadPlugin without any 
trouble. I then added a new class to the plugin - it is derived from a 
class that is defined in the main application, which has numerous 
virtual functions. If I don't override those functions in the new class, 
everything works fine (as far as loading is concerned), but all I have 
to do is uncomment one in the header file, and suddenly dlsym no longer 
finds LoadPlugin. Any clues?

If there is different mailing list that this should be posted on, please 
  let me know.

Thanks,

Chris Hennes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamic loader and virtual functions
  2002-08-17  5:28 Dynamic loader and virtual functions Chris Hennes
@ 2002-08-17  5:53 ` bjorn rohde jensen
  2002-08-17  6:16   ` Chris Hennes
  0 siblings, 1 reply; 6+ messages in thread
From: bjorn rohde jensen @ 2002-08-17  5:53 UTC (permalink / raw)
  To: chennes; +Cc: gcc-help

Hi Chris,

 You have to be pretty careful, when with all the
funny C++ stuff, when you want binary compatibility
between different versions of libraries. The biggest
issue, i would say, is, that the (runtime) linker
has to deal with all the nasty implementation details
of the language, so, what at the language level looks
very nice and compatible, might look completely
incompatible at the link level. Try looking at:

http://developer.kde.org/documentation/library/kdeqt/kde3arch/devel-binarycompatibility.html

You will find some simple guidelines there on how
to do this sort of thing. What you did is on the
list of things not to do...

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamic loader and virtual functions
  2002-08-17  5:53 ` bjorn rohde jensen
@ 2002-08-17  6:16   ` Chris Hennes
  2002-08-17  8:02     ` bjorn rohde jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Hennes @ 2002-08-17  6:16 UTC (permalink / raw)
  To: bjensen; +Cc: gcc-help

Bjorn et. al,

Thanks for the input, and for the link. Unfortunately, binary 
compatibility does not seem to be the issue here. This problem appears 
even if I change the class to not inherit from anything. I add a virtual 
function in the header and poof! dlsym can't find the extern "C" function.

What's really strange is that this new class is being instantiated as a 
member of the main class for this plugin. In each plugin, this main 
class is derived from a plugin base class in the main application which 
contains virtual functions. The plugin class overrides these virtual 
function (successfully), and this has no effect on dlsym finding the 
LoadPlugin function. Why is this suddenly appearing when I add a new 
class with virtual functions to the .so???

Chris

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamic loader and virtual functions
  2002-08-17  6:16   ` Chris Hennes
@ 2002-08-17  8:02     ` bjorn rohde jensen
  2002-08-17  8:10       ` Chris Hennes
  0 siblings, 1 reply; 6+ messages in thread
From: bjorn rohde jensen @ 2002-08-17  8:02 UTC (permalink / raw)
  To: chennes; +Cc: gcc-help

Hi Chris,

 You have checked, that the function in question
is actually in the .so, right? What does dlerror
report as the reason for not being able to find
the function? Could it be a problem with unresolved
references instead of compatibility issues?

Yours sincerely,

Bjorn

Ps: I am pretty sure, the problem is unrelated to gcc/g++:)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamic loader and virtual functions
  2002-08-17  8:02     ` bjorn rohde jensen
@ 2002-08-17  8:10       ` Chris Hennes
  2002-08-17 11:19         ` bjorn rohde jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Hennes @ 2002-08-17  8:10 UTC (permalink / raw)
  To: bjensen; +Cc: gcc-help

Bjorn,

You are correct - the problem was unrelated to gcc (not surprisingly!). 
Thanks for your help. The problem was an undefined virtual function - 
the way the error manifested itself confused me -- I'm relatively new to 
manually dynamic loading.

Again, thanks,

Chris Hennes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamic loader and virtual functions
  2002-08-17  8:10       ` Chris Hennes
@ 2002-08-17 11:19         ` bjorn rohde jensen
  0 siblings, 0 replies; 6+ messages in thread
From: bjorn rohde jensen @ 2002-08-17 11:19 UTC (permalink / raw)
  To: chennes; +Cc: gcc-help

Hi Chris,

 I am delighted to hear, you got things working
nicely again. Dynamic loading is rather complicated,
and one has to appriciate the trouble gcc/g++ goes
through to lighten ones work by driving the system
linkers:)

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-08-17 18:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-17  5:28 Dynamic loader and virtual functions Chris Hennes
2002-08-17  5:53 ` bjorn rohde jensen
2002-08-17  6:16   ` Chris Hennes
2002-08-17  8:02     ` bjorn rohde jensen
2002-08-17  8:10       ` Chris Hennes
2002-08-17 11:19         ` bjorn rohde jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).