It's great that you solved it but allow me to say that in my opinion it is not a robust solution if you will ever try to distribute this to other users or even if you install it on other systems, OSX or not. It only works if you called your module via that specific Ruby program. So that excludes the stand-alone use of your module. And provided that the installer of your module has placed the library in 'lib/perl5'. And because DYLD_LIBRARY_PATH is OSX specific. And because adding (in your case it is "setting" as you discard any previous content) DYLD_LIBRARY_PATH can interfere with other things including being able to call the perl interpreter itself. If you do it via terminal, it will affect all future commands on that same terminal only, if you do it via your shell init (.bashrc e.g.) will affect all commands you run under bash and if you do it in the Ruby script, it may affect all system commands run from within (I think?). For this the bash idiom DYLD_LIBRARY_PATH=/thepath command can be useful as it sets that env var for just running "command".

I think the cleanest would be to do it via the XSLoader/DynaLoader by solving the problem at its root. But if it works as is, hey good job!

bw, bliako


In reply to Re^7: XSLoader/DynaLoader Can't Locate Library by bliako
in thread XSLoader/DynaLoader Can't Locate Library by wbirkett

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.