dlopen and CPP

Hi I have built a shared object using CPP.But my problem is that when i do
dlsym for a static function(I don’t know if i can do dlsym for the public
functions in the class.) I am getting an error symbol not found.

I am doing something like this.
The File in which i am doing dlopen is a “C file”
handle = dlopen ("/root/samp_cpp.so",RTLD_NOW);
fn1 = (fn*) dlsym (handle,“count::xxx”);
if(fn1)
(*fn1)(…);
else
print("%s",dlerror());

I always get the error “symbol not found”
My Question are these

  1. Are there any special flags to be used to build a .so file when using
    …cpp files.?
  2. Is the above method correct in calling the dlsym.It worked perfectly for
    me if i were to call a c function.?
  3. Is it possible to call a public function in the class using
    dlsym(provided i have the pointer for the object)?

Any help is greatly appreciated.

Sreekanth

The issue is you need to know how the name was mangled. C++ does not use
the name you give the function directly unless it is tagged with
‘extern “C”’. I am not sure if you can do that to a static class member
or not. Also, there is no portable way to guess the mangled name.

chris


Sreekanth <sreekanth@cambira.com> wrote:

Hi I have built a shared object using CPP.But my problem is that when i do
dlsym for a static function(I don’t know if i can do dlsym for the public
functions in the class.) I am getting an error symbol not found.

I am doing something like this.
The File in which i am doing dlopen is a “C file”
handle = dlopen ("/root/samp_cpp.so",RTLD_NOW);
fn1 = (fn*) dlsym (handle,“count::xxx”);
if(fn1)
(*fn1)(…);
else
print("%s",dlerror());

I always get the error “symbol not found”
My Question are these

  1. Are there any special flags to be used to build a .so file when using
    .cpp files.?
  2. Is the above method correct in calling the dlsym.It worked perfectly for
    me if i were to call a c function.?
  3. Is it possible to call a public function in the class using
    dlsym(provided i have the pointer for the object)?

Any help is greatly appreciated.

Sreekanth
\

cdm@qnx.com > “The faster I go, the behinder I get.”

Chris McKillop – Lewis Carroll –
Software Engineer, QSSL
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Also, this has little to do with the network DDK.

-seanb

Chris McKillop <cdm@qnx.com> wrote:
: The issue is you need to know how the name was mangled. C++ does not use
: the name you give the function directly unless it is tagged with
: ‘extern “C”’. I am not sure if you can do that to a static class member
: or not. Also, there is no portable way to guess the mangled name.

: chris


: Sreekanth <sreekanth@cambira.com> wrote:
:>
:> Hi I have built a shared object using CPP.But my problem is that when i do