This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
pure virtual problems with dlopen()
- To: gcc at gcc dot gnu dot org
- Subject: pure virtual problems with dlopen()
- From: Ralph Seguin <rpseguin at yahoo dot com>
- Date: Wed, 19 Jan 2000 01:49:33 -0800 (PST)
- Cc: Ralph Seguin <rpseguin at yahoo dot com>
Hi. I'm in the process of writing a plugin framework
and I've run into a glitch with pure virtual methods
and dlopen(). I did some searching and turned up some
similar cases, but not obvious fixes.
I've got an asbstract base class: 'base'
class base
{
public:
virtual ~base () {}
virtual void someMethod () = 0;
};
And a derived class: 'derived'
class derived : public base
{
public:
// blah blah blah
virtual void someMethod ()
{
// Do something here.
}
};
When I compiled derived into an .so (which isn't
quite working as expected either, more on that later),
nm shows derived.so as having __pure_virtual being
unresolved:
outof:rpsPlugin % nm testPlugin.so | fgrep -i pure
U __pure_virtual
I tracked it down in libg++.so and libgcc, but I'm
surprised that g++ isn't linking this in whilst I
compile:
g++ -shared -Wall -I. -g -shared -c testPlugin.cpp
-o testPlugin.o
ld -g -Bdynamic -shared testPlugin.o -soname
testPlugin.so -o testPlugin.so
If I make base concrete by giving base::someMethod() a
body, dlopen() works (cause __pure_virtual isn't
unresolved).
For some reason:
g++ -shared -Wall -I. -g -c testPlugin.cpp -o
testPlugin.so
does NOT create something that dlopen() is comfortable
with opening, but if I use ld as above, I can dlopen()
it.
This command just doesn't work as I expect it to:
g++ -shared -Wall -I. -g -c testPlugin.cpp -o
testPlugin.so -lg++
pg++: cannot specify -o with -c or -S and multiple
compilations
Thanks.
-Ralph
rpseguin@yahoo.com
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com