This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: C++, dlopen() and undefined __pure_virtual
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Banibrata Dutta <dutta at india dot hp dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 23 Apr 2004 08:58:29 -0700
- Subject: Re: C++, dlopen() and undefined __pure_virtual
- References: <008101c4294b$41680a80$c0714c0f@nt13192>
On Fri, Apr 23, 2004 at 09:24:26PM +0530, Banibrata Dutta wrote:
> hi,
>
> i have a peculiar scenario. let me explain it briefly, and my
> problem had something to do with demand loading via
>
> A B C
> ^ ^ ^
> | | |
> X Y Z
>
> i.e. A, B and C are 3 base classes and X, Y, Z are their
> concrete implementations. the program's main() uses the interface
> exposed by A, B & C i.e. the virutal functions, to invoke the
> real implementation in X, Y, Z class.
>
> i have 1 binary (executable) that contains A,B,C amongst other
> things, and a shared object e.g. xyz.so containing X,Y & Z.
>
> conceptually what i want to do is to:
>
> handle = dlopen("./libxyz.so", RTLD_GLOBAL);
> createAobjPtr = (A_FNPTR*) dlsym(handle, "createAobj");
> A *aPtr = (*createAobjPtr)();
>
> everything goes file and links well. but when i run the executable
> it fails saying (due to my calling dlerror()), that:
>
> libxyz.so: undefined symbol: __pure_virtual
>
> what is happening ?? what is really the cause ??
>
> i've created the shared object as follows:
> $ ld -shared -soname libxyz.so -o libxyz.so -lc X.o -lc Y.o -lc Z.o -lc A.o
> -lc B.o -lc C.o -lpthread -lm -ldl
Are you running Linux? If yes, use "g++ -shared", not "ld -shared".
H.J.