This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++, dlopen() and undefined __pure_virtual


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

note that it became necessary to also link into A.o,B.o,C.o in libxyz.so, as
otherwise it would crib on the corresponding type_info being not available.

i've compiled my application as follows:
$ g++ Main.o A.o B.o C.o -o MyApp.exe -Wl,-rpath,/thirdParty/lib -lpthread
-lm -ldl -Wl,-a,shared

where /thirdParty/lib contains some third party libraries which also get
linked in into libxyz.so (not shown), and MyApp.exe is the binary, and i get
the error on running this binary.

any pointers would be highly appreciated.

thanks & regards,
Banibrata Dutta
  Hewlett-Packard ISO Pvt. Ltd,
  29, Cunningham Road,
  Bangalore - 560052, India.
  Tel: +91-80-22051796
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]