This is the mail archive of the cygwin-xfree@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: dlopen error


"Suhaib M. Siddiqi" <ssiddiqi@inspirepharm.com> writes:
> Mumit once mentioned that dlopn error is a bug in Cygwin.
> Anyone has any suggestions on a wrokaround for the following problem?
> When I satrt X-server for Glide, I get dlopen error *unable to open lib:
> dlopen: Win32 error 127*.
> The dll is in path.  libGGI finds it and reports the correct
> path:/usr/local/lib/ggi\display/glide-0-0-0.dll, but still returns the
> dlopen failure.

Here's a quick test program to see if you can load ggi-0-0-0.dll using
dlopen succesfully. Run it with the full pathname as in ggi does and
see what happens.

Another problem is all the DLLs are based at default 0x10000000, and 
causes relocation all over the place. I added code dllwrap precisely
because of this to use the output filename as a hash key and generate
a base address (if not user specified of course) to avoid this relocation
and resultant excessive copying by windows32 loader.

You'll need to at some point build the whole thing with -g and run it
under gdb. No easy way, sorry.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>

/* see comment about 2nd arg to dlopen on Cygwin. */
#ifndef RTLD_GLOBAL
# define RTLD_GLOBAL 0
#endif

int 
main (int argc, char *argv[])
{
  void *dll_handle;
  char *dllname;
  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s dll-name\n", argv[0]);
      return 1;
    }
  dllname = argv[1];

  printf ("PATH = %s\n", getenv ("PATH"));

  /* the second arg is ignored on Cygwin, here for exposition only. */
  dll_handle = dlopen (dllname, RTLD_LAZY | RTLD_GLOBAL);
  if (! dll_handle)
    {
      fprintf (stderr, "%s\n", dlerror ());
      return 1;
    }
  
  printf ("Success: DLL handle %x\n", dll_handle);
  dlclose (dll_handle);
  return 0;
}



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