This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

Re: [Q] How to load dll's at runtime


Hi Stephen, thanks for the response!  And your's too Sergey, I have read
everything from the cygnus web site that seemed relevant now.

Stephen Vance wrote:
> 
>  First, I heard that the header dlfcn.h had problems in this release
> of Cygwin.  That could cause problems.  I think you can download the
> source and copy it from there to patch things up.

Indeed, there is no dlfcn.h in the b19 cdk.exe!  And the defaults that
glib falls back on don't work at all.  I have done as you suggested, and
copied (one of the two!) dlfcn.h files from the source into the
compiler's include path.  

Well I on familiar ground again now that I can use the dlsym api, but
that get's me only about 75% of the way there.

> Here's a code snippet: 
> 
> void *open_symbol( const char *libname, const char *funcname )
> {
> 
>     void *libhandle;
> 
>     libhandle = dlopen( libname, RTLD_LAZY );
>     if( libhandle == NULL )
>         return NULL;
> 
>     return dlsym( libhandle, funcname );
> }
> 
> int (*func)( int, char *); // For example
> 
> func = open_symbol( "mylib.dll", "myfunc" );
> 
> (*func)( myint, mycharstar );
> 
> Invoking dlsym with a NULL libhandle give you a handle to the
> executable.

dlsym you say?  I am used to using

   libhandle = dlopen (NULL, RTLD_NOW|RTLD_LAZY);

to get an introverted handle.  However I don't seem to be able to get
either of them to work.  I have followed the execution through with gdb,
and in either case it fails inside cygwin.dll, with 

   error: dlopen: Win32 Error #126

and

   error: dlsym: Win32 Error #87

respectively.

>  On some systems, this means *precisely* the executable
> (Sun, NT); on others it means the executable and any shared library
> explicitly linked with it (SGI, HP).  I suspect Cygwin will behave
> the same way as the regular NT stuff.

Any other clues you might be able to help me with?

I fear that there may be no support for the introspective handler within
b19... but even confirmation of this would be good.

Thanks for your patience.

Gary.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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