unresolved symbol for C++ class dtor
Gergely CZUCZY
phoemix at harmless.hu
Wed Dec 27 09:31:42 PST 2006
hello
i've written a testprogram to check how dynamic linking
works for C++ code, specially for class, when are global objects'
ctors and dtors are being called etc.
however, i've run into a very strange problem.
in the main program i have a "class module", which has
a virtual destructor. The dlopen()'d module has a class
derived from this one.
Main program:
class module {
public:
module();
virtual ~module();
};
mod_bar:
class modbar: public module {
public:
modbar(): module() {};
~modbar() {};
};
Of course the main program's module class's methods are
not just declared they are also defined elsewhere.
This is the way i try to dlopen() mod_bar:
if ( !(dh = dlopen(MOD_BAR, RTLD_NOW|RTLD_GLOBAL)) ) {
...
}
i've got the following error message when running the code:
Unable to dlopen(lib/mod_bar.so): lib/mod_bar.so: Undefined symbol "_ZN6moduleD2Ev"
however, i've check the testprogram:
$ nm bin/dltest | grep _ZN6moduleD2Ev
08048918 T _ZN6moduleD2Ev
so it does exist.
i've tried to compile the binaries both without and without -fpic -fPIC,
but nothing had changed.
the question is, what am i doing wrong? according to the symbols,
the dynamic linker should be able to load that symbol, however it doesn't.
what do i need to do to fix this?
looking forward for answers,
Bye,
Gergely Czuczy
mailto: gergely.czuczy at harmless.hu
--
Weenies test. Geniuses solve problems that arise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 1499 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20061227/e3554089/attachment.pgp
More information about the freebsd-hackers
mailing list