develooper Front page | perl.perl5.porters | Postings from December 2007

RE: How to load a "loadable object" that has a non-default file extension ?

Thread Previous | Thread Next
Jan Dubois
December 14, 2007 11:09
RE: How to load a "loadable object" that has a non-default file extension ?
Message ID:
On Fri, 14 Dec 2007, Craig A. Berry wrote:
> A better solution than changing the file extension would be changing
> the name of the loadable object so you would have, for example
> PL_PGPLOT.dll or Perl_DLL_PGPLOT.dll (or similar) for the Perl
> extension and avoid the namespace collision with pgplot.dll in the
> registry (or wherever it is the collision is happening). We've done

This is actually what he was doing with $dl_dlext: By setting it to
'xs.dll' he essentially just tacked on 'xs' to the name, but kept the
extension as is.

The namespace collision happens at runtime in the loader: dynamic references
are resolved against the library name, so if you load multiple files
with the same library name, the loader maps all symbols for that library
to just one instance (the first one loaded, I believe).  This is not
an issue if you load libraries with full pathname at runtime and resolve
symbols explicitly using GetProcAddress (dlopen() and dlsym() on Unix),
but all symbols that need to be resolved implicitly by the loader use
just the library name).

> this on VMS for years. You need to create a C<mod2fname> built-in (see
> as an example what's in vms/vms.c), load it as
> C<DynaLoader::mod2fname>, and the existing infrastructure in
> DynaLoader should take care of the rest.
> Any platform for which there is a single system-wide (or even process-
> wide) namespace for loadable objects should definitely not be creating
> Perl extensions without mangling the name in some way.

An interesting idea, but not backwards compatible, so it can't be
introduced on Windows until Perl 5.12.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About