Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

the crude and possibly bad+dirty way to do this is to prepend to your LD_LIBRARY_PATH **AND** DYLD_LIBRARY_PATH the directories you want ld to look for libraries.

Those are environment variables. So don't control them within the perl script (like you seem to do). You either set them temporarily at the command line prior to executing your perl script, or insert them to your shell startup script (like ~/.bashrc if using bash) for permanent use (I don't recommend).

This latter method is not proper as I already mentioned because it applies for all your applications run from your shell (so those at the launcher will not be affected unless they are launched via a shell which reads your startup files - (sanity chek: I believe?)).

Therefore, if you had perlbrew installed, setting those two env vars would theoretically invalidate brew's ability to control perl's loading procedure. In practice, possibly perlbrew knows better and overwrites those. I am not sure though. But any other application - outside perl - which relies on finding a png library it will find first your other libraries and the chaos starts. That's also the classic way to hack root from within because who controls your libraries and lib search path controls you.

Here is the most harmless bash idiom to do the above:

LD_LIBRARY_PATH="/path1:/path2:${LD_LIBRARY_PATH}" DYLD_LIBRARY_PATH="/path1:/path2:${DYLD_LIBRARY_PATH}" myperlscript.pl

Edit: warning, if you use OSX's archaic /bin/bash these may not work. Hint: change your login shell to modern bash (e.g. the one installed by macports). Do not, I repeat, do not link macports bash to /bin/bash!

It launches your script with those env vars set only once for just that run. If you must go this way, then perhaps you could create a wrapper shell script to run your perl script the way I said above. Similarly, alter your perl script's shebang to point to a perl wrapper which sets those env vars first and then calls the proper perl to interpret your script. By know you are re-inventing perlbrew ...

Or investigate how to set ENV within you Perl script so that subsequent use will use it. Others are more experts in this. Search the monastery too, I recall this came up recently.

Another alternative is to configure Perl's DynaLoader. I do not know if it is possible to tell it where to look for libs other than what I said above, with those two env vars. I.e. whether DynaLoader relies on ld or it has a mind of its own (unlikely i presume).

bw, bliako


In reply to Re: Include custon location for dylib by bliako
in thread Include custon location for dylib by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found