Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: XSLoader/DynaLoader Can't Locate Library

by bliako (Monsignor)
on Jun 10, 2020 at 19:47 UTC ( [id://11117914]=note: print w/replies, xml ) Need Help??


in reply to XSLoader/DynaLoader Can't Locate Library

Perhaps there are some extra files libRmath.dylib depends on which you have not moved? Perhaps this can tell you more, if it works: export LD_DEBUG=all . Or use the nuclear deterrent: strace -f -e trace=open,close,read,write,connect,accept perl xx.pl | grep libRmath (and without the grep perhaps).

Have you tried to use only DynaLoader, re: https://metacpan.org/pod/XSLoader#Migration-from-DynaLoader

What does this show?

require DynaLoader; print "@DynaLoader::dl_library_path\n";

bw, bliako

Replies are listed 'Best First'.
Re^2: XSLoader/DynaLoader Can't Locate Library
by wbirkett (Acolyte) on Jun 10, 2020 at 21:00 UTC

    Thank you, bliako, for your suggestions. Unfortunately, strace is not available on my Mac. I wasn't able to coax any additional debug information. I also tried setting the $dl_debug flag.

    I did modify the Rmath.pm file to use the DynaLoader module instead of XSLoader, sort of a reverse migration. The result was the same, even when pushing the exact .dylib folder path onto @DynaLoader::dl_library_path. When I add code to the .bs file, it is executed, so I used that to modify @DynaLoader::dl_library_path.

    The default values for @DynaLoader::dl_library_path are '/usr/lib' and '/usr/local/lib'. The library loads correctly from either of those locations. I was able to load the library from other locations using the dl_load_file() function.

      When I add code to the .bs file, it is executed, so I used that to modify @DynaLoader::dl_library_path.

      What about adding that code in the actual .pm file you created (Rmath.pm?) like:

      package Rmath; ... our @ISA = qw( ... DynaLoader ... ); require DynaLoader; push @DynaLoader::dl_library_path, 'my-nonstandard-lib-path'; print "XXX=$_\n" for @DynaLoader::dl_library_path; bootstrap <Yourmodule> $VERSION;

      $dl_debug : I meant doing export LD_DEBUG=all in your terminal/shell/prompt before testing your program (on that same terminal).

      There are two very remote possibilities: 1) the dylib extension is not tried at all in enumerating possible library names (unlikely because it finds it in standard lib location), 2) the spaces in the library path (in OSX hmm that's not likely).

      ps. the reason I suggested this reverse-migration is to investigate DynaLoader's behaviour without the front-man.

        While trying your suggestion, I may have stumbled on the cause of my problem. I modified the .pm file as you suggested, and ran my test file. The library paths were printed as you'd expect, but the library still did not load. I wanted to be sure the library was actually where I specified, so I cd'd to that folder and did a directory listing. Then I ran the test file again, and the library loaded!!

        WBBirkett-M:perl5 wbirkett$ cd ~/ WBBirkett-M:~ wbirkett$ perl -I/Users/wbirkett/Library/Application\ Su +pport/TextMate/Pristine\ Copy/Bundles/PressCal.tmbundle/Support/lib/p +erl5 /Users/wbirkett/Desktop/Rmath_test.pl XXX=/usr/lib XXX=/usr/local/lib XXX=/Users/wbirkett/Library/Application Support/TextMate/Pristine Copy +/Bundles/PressCal.tmbundle/Support/lib/perl5 Can't load '/Users/wbirkett/Library/Application Support/TextMate/Prist +ine Copy/Bundles/PressCal.tmbundle/Support/lib/perl5/darwin-thread-mu +lti-2level/auto/ICC/Support/Rmath/Rmath.bundle' for module ICC::Suppo +rt::Rmath: dlopen(/Users/wbirkett/Library/Application Support/TextMat +e/Pristine Copy/Bundles/PressCal.tmbundle/Support/lib/perl5/darwin-th +read-multi-2level/auto/ICC/Support/Rmath/Rmath.bundle, 1): Library no +t loaded: libRmath.dylib Referenced from: /Users/wbirkett/Library/Application Support/TextMat +e/Pristine Copy/Bundles/PressCal.tmbundle/Support/lib/perl5/darwin-th +read-multi-2level/auto/ICC/Support/Rmath/Rmath.bundle Reason: image not found at /System/Library/Perl/5.18/darwin-thread-m +ulti-2level/DynaLoader.pm line 194. at /Users/wbirkett/Desktop/Rmath_test.pl line 1. Compilation failed in require at /Users/wbirkett/Desktop/Rmath_test.pl + line 1. BEGIN failed--compilation aborted at /Users/wbirkett/Desktop/Rmath_tes +t.pl line 1. WBBirkett-M:~ wbirkett$ cd /Users/wbirkett/Library/Application\ Suppor +t/TextMate/Pristine\ Copy/Bundles/PressCal.tmbundle/Support/lib/perl5 WBBirkett-M:perl5 wbirkett$ perl -I/Users/wbirkett/Library/Application +\ Support/TextMate/Pristine\ Copy/Bundles/PressCal.tmbundle/Support/l +ib/perl5 /Users/wbirkett/Desktop/Rmath_test.pl XXX=/usr/lib XXX=/usr/local/lib XXX=/Users/wbirkett/Library/Application Support/TextMate/Pristine Copy +/Bundles/PressCal.tmbundle/Support/lib/perl5 OK

        So, the failure to load the library is somehow connected to the current directory in the Terminal app. I don't know why that would matter, but it looks this is a macOS problem, not a Perl problem.

        Thank you again for your help.

      >strace is not available on my Mac

      man dtruss

      «...strace is not available on my Mac.»

      dtruss?

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117914]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found