If you want it to take effect for XML::Parser::Expat, you have to put the declaration in ./Expat/Makefile.PL, not ./Makefile.PL.

For example, your ./Expat/Makefile.PL could read:

... WriteMakefile( NAME => 'XML::Parser::Expat', C => ['Expat.c'], LIBS => $libs, XSPROTOARG => '-noprototypes', VERSION_FROM => 'Expat.pm', LDDLFLAGS => $Config{lddlflags}." -Wl,-rpath,$ENV{ORIGIN}/../lib", + # <-- add this @extras );

Sample build session:

$ ORIGIN=/usr/local/foo/bar perl Makefile.PL Writing Makefile for XML::Parser::Expat Writing Makefile for XML::Parser $ make ... rm -f ../blib/arch/auto/XML/Parser/Expat/Expat.so LD_RUN_PATH="/lib" gcc -shared -O2 -L/usr/local/lib -fstack-protecto +r -Wl,-rpath,/usr/local/foo/bar/../lib Expat.o -o ../blib/arch/auto/ +XML/Parser/Expat/Expat.so \ -lexpat \ ... $ readelf -d ./blib/arch/auto/XML/Parser/Expat/Expat.so | grep Lib 0x000000000000000f (RPATH) Library rpath: [/usr/local/fo +o/bar/../lib] 0x000000000000001d (RUNPATH) Library runpath: [/usr/local/ +foo/bar/../lib]

Similarly with the dynamic_lib => { ... } variant:

WriteMakefile( NAME => 'XML::Parser::Expat', C => ['Expat.c'], LIBS => $libs, XSPROTOARG => '-noprototypes', VERSION_FROM => 'Expat.pm', dynamic_lib => { OTHERLDFLAGS => "-Wl,-rpath,$ENV{ORIGIN}/../lib" }, @extras );
$ ORIGIN=/usr/local/foo/bar perl Makefile.PL Writing Makefile for XML::Parser::Expat Writing Makefile for XML::Parser $ make ... rm -f ../blib/arch/auto/XML/Parser/Expat/Expat.so LD_RUN_PATH="/lib" gcc -shared -O2 -L/usr/local/lib -fstack-protecto +r Expat.o -Wl,-rpath,/usr/local/foo/bar/../lib -o ../blib/arch/auto/X +ML/Parser/Expat/Expat.so \ -lexpat \ ... $ readelf -d ./blib/arch/auto/XML/Parser/Expat/Expat.so | grep Lib 0x000000000000000f (RPATH) Library rpath: [/usr/local/fo +o/bar/../lib] 0x000000000000001d (RUNPATH) Library runpath: [/usr/local/ +foo/bar/../lib]

(Note the "-Wl,-rpath,/usr/local/foo/bar/../lib" part in the linking commands above, and its different position.)


In reply to Re^5: Editing RPATH of Perl module XML::Parser by Eliya
in thread Editing RPATH of Perl module XML::Parser by virtualdj

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.