dlsym failed
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > dlsym failed




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    dlsym failed  
shahan.am@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-09-07 06:26 PM

Hi
I want to get a address of a function at runtime by using dlsym. This
is the sample code i have written.
(This is a sample code. In actual implementation _CreateVirtualProcess
in a seperate shared library)

//--Main.cpp
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dlfcn.h>
#ifdef SUNOS
#include <sys/filio.h>
#else
#include <sys/ioctl.h>
#endif

extern "C" pid_t _CreateVirtualProcess(void (*func)(int))
{
/*Implementation*/
return getpid();
}

pid_t __CreateVituralProcess(void (*func)(int))
{
static pid_t (*_create_virtual_process)(void (*)(int)) = NULL;
if (_create_virtual_process == NULL)
{
char* zdlerror = dlerror();
void *p = dlsym(RTLD_DEFAULT,
"_CreateVirtualProcess");
_create_virtual_process = (pid_t (*)(void (*)(int)))p;
if ((zdlerror = dlerror()) != NULL)
{
fprintf (stderr, "%s\n", zdlerror);
return -1;
}
}
return (*_create_virtual_process)(func);
}
int main ()
{
printf("pid = %d\n", __CreateVituralProcess(NULL));
return 0;
}
In Solaris SPARC (5.9) with g++ (3.4.6)  i build it by g++ -ott
Main.cpp -DSUNOS.
when executing it fails by giving "ld.so.1: tt: fatal:
_CreateVituralProcess: can't find symbol"..

but Solaris x86 (5.10) with g++ (3.4.3) its working fine.
i tried it in red hat linux with g++ (3.2.3 ) also failed.

what went wrong there ? how should i correct the problem ?

Thank you..






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:57 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register