Bonjour Jean-Louis,

On 18.07.2021 00:02, Jean Louis Faucher wrote:
> I have an atypical configuration where I use DYLD_LIBRARY_PATH to locate the 
> BSF4OORexx library.
> This is because I don’t “install” BSF4OORexx, I just unzip the delivery, copy 
> and rename the
> libraries to bsf4oorex/install/64
> With this configuration, your test cases are working (not saying this is the 
> solution).

It seems that at least with macOS Big Sur (version 11.4) DYLD_LIBRARY_PATH does 
not work anymore
(for "security reasons"), as well as anything not rooted on the Mac computer 
gets quarantined (got
the same problem as with ooRexx and BSF4ooRexx from the Internet when I 
installed OpenOffice 4.1.10
yesterday), so one needs to remove the com.apple.quarantine extended attribute 
with xattr before the
packages become operable again. (Personally, I think that it is high time that 
someone has to stop
Apple to deprive the owners of Apple computers and also the Apple software 
developers.)

Cf. e.g. <https://developer.apple.com/forums/thread/13161> at the bottom where 
LD_LIBRARY_PATH and
anything starting with DYLD_LIBRARY_PATH gets ignored all of a sudden, also
<https://stackoverflow.com/questions/60126159/how-to-set-ld-library-path-dyld-library-path-on-macos>
at the bottom. Some background here: 
<https://news.ycombinator.com/item?id=23612772>, here the
authorative description:
<https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html>.


[A few months ago I read that if one would run a copy of the shell program from 
the user location
then it would work. Tried it, but  could not get it to work.]

> If I don’t set DYLD_LIBRARY_PATH, I get the same error than yours.
>
> I compared the output of the next command in both cases
> DYLD_PRINT_LIBRARIES="1" DYLD_PRINT_APIS="1" rexx -e "call bsf.cls”
>
> In the working session:
> dlopen(librexxapi.dylib, 0x00000001)
>   dlopen(librexxapi.dylib) ==> 0x10936da50
> dlopen(libBSF4ooRexx.dylib, 0x00000001)
> dyld: loaded:
> /local/rexx/bsf4oorexx/BSF4ooRexx_install_v641-20210715-beta/bsf4oorexx/install/64/libBSF4ooRexx.dylib
> dyld: loaded:
> /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib
> dyld: loaded: /usr/lib/libstdc++.6.0.9.dylib
>
> In the not working session:
> dlopen(librexxapi.dylib, 0x00000001)
>   dlopen(librexxapi.dylib) ==> 0x10dd4a990
> dlopen(libBSF4ooRexx.dylib, 0x00000001)
>   dlopen() failed, error: 'dlopen(libBSF4ooRexx.dylib, 1): image not found'
> dlopen(/usr/lib/libBSF4ooRexx.dylib, 0x00000001)
>   dlopen() failed, error: 'dlopen(/usr/lib/libBSF4ooRexx.dylib, 1): image not 
> found'
>    919 *-* ::routine xBSF                   PUBLIC   EXTERNAL "LIBRARY 
> BSF4ooRexx BSF            
>     "
>      1 *-* call bsf.cls
> Error 98 running 
> /local/rexx/bsf4oorexx/BSF4ooRexx_install_v641-20210715-beta/bsf4oorexx/BSF.CLS
> line 919:  Execution error.
> Error 98.903:  Unable to load library "BSF4ooRexx".
>
Wow, learned about "DYLD_PRINT_LIBRARIES" and "DYLD_PRINT_APIS", very useful!

> I find "/usr/lib” in one file:
> SysLibrary.cpp
>
>     // try loading directly
>     libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
>     // if not found, then try from /usr/lib
>     if (libraryHandle == NULL)
>     {
>         sprintf(nameBuffer, "/usr/lib/lib%s%s", name, ORX_SHARED_LIBRARY_EXT);
>         libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
>
> The part to investigate is how to make the first dlopen work without using 
> DYLD_LIBRARY_PATH:

Indeed.

> If I put libBSF4ooRexx.dylib in the lib folder of oorexx then it works 
> (RPATH).

Tried it on 11.4, but unfortunately does not work. It may have to do with 

... cut ...

While adding debug statements to SysLibrary.cpp (adding "/usr/local/lib" as 
another explicit
location) and using dlerror() I just got: "Library not loaded: 
"@rpath/libjvm.dylib | Referenced
from: /usr/local/lib/libBSF4ooRexx.dylib | Reason: image not found!".

This is strange as BSF4ooRexx explicitly looks in different locations for 
libjvm.dylib and is not
compiled with rpath in effect. And the first location 
("/opt/BSF4ooRexx/libjvm.dylib") exists in
this case (as a symbolic link) such that dlopen("/opt/BSF4ooRexx/libjvm.dylib", 
RTLD_LAZY |
RTLD_GLOBAL) should succeed. It seems that somehow ooRexx loading 
libBSF4ooRexx.dylib also causes an
error as "@rpath/libjvm.dylib" would not exist.

Adding a symbolic link to libjvm.dylib to ooRexx' lib directory indeed makes 
libBSF4ooRexx.dylib
load successfully! Interestingly, the code in BSF4ooRexx gets excercised then
"/opt/BSF4ooRexx/libjvm.dylib" gets loaded and not "@rpath/libjvm.dylib"!

Or with other words: ooRexx will find "libBSF4ooRexx.dylib", but cannot load it 
successfully because
dlopen() is not able to find "@rpath/libjvm.dylib" (which is somewhere else and 
will be searched for
in different locations). But I am stumped that that would be the case at all as 
rpath is not
explicitly defined for creating the libBSF4ooRexx.dylib with g++, it gets 
linked against an
installed, existing libjvm.dylib. 

<https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling> 
has a section on Mac,
but I found not yet a solution.

Any ideas, hints and pointers highly welcome!

---rony

P.S.:

Java seems to be able to load "libBSF4ooRexx.dylib" nevertheless (in that use 
case Java, i.e.
libjvm.dylib, is already running so dlopen() will probably fetch it from the 
loaded modules)!







_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to