Really, if you need to know exactly where you were loaded from, I’d
do something like this…
#include <errno.h>
#include <dlfcn.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void *my_dlopen( const char *name, int mode, char *path )
{
char *libpath, *tmppath;
libpath = getenv( “LD_LIBRARY_PATH” );
if ( libpath == NULL ) {
len = confstr( _CS_LIBPATH, NULL, 0 );
if ( len > 0 ) {
libpath = malloc( len + 1 );
confstr( _CS_LIBPATH, libpath, len );
}
}
tmppath = pathfind( libpath?:"", name, “rx” );
if ( tmppath == NULL )
return errno = ESRCH, NULL;
if ( path )
strcpy( path, tmppath, strlen(tmppath) );
return dlopen( tmppath, mode );
}
Beth <id@address.com> wrote:
Colin, thanks for your response.
I have this library file libfs.so that is linked by libsw.so at compile
time. Both libraries are installed in the
/fi/lib directory.
The executable program ‘swcore’, that is under /fi/bin, calls dlopen() of
libsw.so when it starts.
At the init time of the libfs.so library, it calls fopen(“libfs.so”, rb).
Since fopen() only looks at
the directory of where swcore process is running of , fopen() would fail.
Do you have any suggestion as to how I can get around with this problem?
Appreciate your help.
-Beth
Colin Burgess wrote:
This information isn’t stored, only the basename of the libs that have
been loaded.
Sorry, the best way to do it for now is to search the LD_LIBRARY_PATH
yourself.
To be safe, you could do that before you open the dll, then call
dlopen with the fully qualified pathname.
Beth <> id@address.com> > wrote:
Is there an API that is equivalent to Win32’s GetModuleFileName(). I
need to know the path of where the DLL is loading from at runtime.
Appreciate any help.
I have posted this question on qnx.public.qnxrtp.porting, no one seems
to know. Sorry, I have to re-post it here, hope I could get some help.
-Beth
–
cburgess@qnx.com
–
cburgess@qnx.com