in reply to Re^2: Editing RPATH of Perl module XML::Parser
in thread Editing RPATH of Perl module XML::Parser

Try LDDLFLAGS.   As it defaults to $Config{lddlflags} (i.e. perl -V:lddlflags), you have to be careful not to overwrite anything that might be in there already (in other words, whatever you specify does replace, not add/append to it).

As a last resort, you could try OTHERLDFLAGS (which is typically unused). — Usage (in Makefile.PL):

WriteMakefile( ... dynamic_lib => { OTHERLDFLAGS => "-Wl,-rpath,/your/lib/path" }, );

(In the link command in the Makefile, the values are issued in the following order: $(LD) $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) ... )

Replies are listed 'Best First'.
Re^4: Editing RPATH of Perl module XML::Parser
by virtualdj (Initiate) on Dec 14, 2011 at 18:20 UTC

    Hi, unfortunately neither prepending LDDLFLAGS="-R$ORIGIN/../lib" to "perl Makefile.PL" nor editing the Makefile.PL:

    WriteMakefile1( ABSTRACT_FROM => 'Parser.pm', AUTHOR => 'Clark Cooper (coopercc@netheaven.com)', LICENSE => 'perl', MIN_PERL_VERSION => '5.00405', META_MERGE => { resources => { repository => 'http://github.com/chorny/XML-Parser', }, }, #BUILD_REQUIRES => { #}, NAME => 'XML::Parser', DIR => [qw(Expat)], dist => {COMPRESS => 'gzip', SUFFIX => '.gz'}, VERSION_FROM => 'Parser.pm', PREREQ_PM => { LWP => 0, #for tests }, $^O =~/win/i ? ( dist => { TAR => 'ptar', TARFLAGS => '-c -C -f', }, ) : (), dynamic_lib => { OTHERLDFLAGS => "-Wl,-rpath,\$ORIGIN/../lib" }, @extras );

    did work. In fact when I make, see the LD_RUN_PATH variable (it's always the same):

    Running Mkbootstrap for XML::Parser::Expat () chmod 644 Expat.bs rm -f ../blib/arch/auto/XML/Parser/Expat/Expat.so LD_RUN_PATH="/root/perl5/lib" cc -shared -O2 -L/usr/local/lib -fstack +-protector Expat.o -o ../blib/arch/auto/XML/Parser/Expat/Expat.so + \ -L/root/perl5/lib -lexpat \ chmod 755 ../blib/arch/auto/XML/Parser/Expat/Expat.so

      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.)

        Thank you very much! I missed that thing...

        Who's on first?

        Thanks for the chuckle Eliya