Takamoto has asked for the wisdom of the Perl Monks concerning the following question:

How is it possible to load dylib (such as libcrypto.3.dylib) dynamically at runtime, i.e. specifying the location of given library?

Context of what I am trying to achieve: I use pp to pack an heavy application to run it on a different machines. I specify here all dylib, but the final executive becomes heavy and requires a lot of time at startup (unpacking). I want to move the dylib outside the pp executive and ship it with the installation routine.

Replies are listed 'Best First'.
Re: load dylib at runtime
by SankoR (Prior) on Dec 20, 2023 at 16:52 UTC
    FFI::Platypus if you're wrapping the libs yourself. If not, adding the directory you're placing libs in to your LD_LIBRARY_PATH somehow before your script is run would do the trick.
Re: load dylib at runtime
by swl (Prior) on Dec 20, 2023 at 21:14 UTC

    Another approach is to pack everything using pp, but set the PAR_GLOBAL_TEMP environment variable when running the executable (assuming it is via a wrapper script). Set this env var to be a location that is not cleaned up by default, e.g. ~/Library/your_app.

    This does lead to the risk that old versions will not be cleaned up unless your installer goes looking for them. However, there are ways of doing so and you can also make it clear to users what to do.