Menu

#2045 odd behavior of ::requires for external funcions libraries

5.2.0
open
nobody
None
none
5
2026-01-10
2026-01-10
No

environment :
macBook pro
apple sequoia 15.7.3
Apple clang version 17.0.0 (clang-1700.6.3.2)
ooRexx at Rev: 13065 + the fix for bug 2041

the script 'navmath.rex' has a :
::requires "rxmpfr" library

everything works when invoking the script using:
rexx navmath

but when I try :
./navmath.rex

I receive :
[enrico@enrico-mbp rxmpfr]$./navmath.rex
116 - ::requires "rxmpfr" library
Error 98 running /Users/enrico/oorexx_EXTENSIONS/rxmpfr/navmath.rex line 116: Execution error.
Error 98.903: Unable to load library "rxmpfr".

I do not like it, but ...
if I copy my external functions 'DLL's into the installed oorexx lib path everything works,
and You and me really do not want to do that

Enrico

PS ... before You ask

my 'DLL's are in /opt/local/lib
and the variuos environment variables for library search are setup properly

declare -x DYLD_LIBRARY_PATH="/opt/local/lib"
declare -x LD_LIBRARY_PATH="/opt/local/lib"
declare -x LIBRARY_PATH="/opt/local/lib:/usr/local/lib"

Discussion

  • Enrico Sorichetti

    FOLLOW ON ...
    the behavior is NOT odd ,
    I investigated ... it is the normal behavior for apple

    did not take too much to fix it by changing
    /Users/enrico/oorexx_DEVEL/oorexx-MAC.src/common/platform/unix/SysLibrary.cpp

    along the lines of

    bool SysLibrary::load(
    const char name) / required library name /
    /
    ***********/
    / Function: Load a named library, returning success/failure flag /
    /************/
    {
    char nameBuffer[PC_PATH_MAX+PC_NAME_MAX];

    if (strlen(name) > PC_NAME_MAX )
    {
        return false;
    }
    
    printf( "********  trying a generic load ...\n" );
    // since APPLE is smart it recognizes that the head of the chain
    // when using rexx <somename> is a program
    // and the DYLD*/LD* variables are valid
    // using ./<somename>.rex, APPLE flags the head as a script,
    // which invalidates the the DYLD*/LD* variables
    
    snprintf(nameBuffer, sizeof(nameBuffer), "%s%s%s", CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX );
    libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
    if ( libraryHandle )
    {
        return true;     // loaded successfully
    }
    
    printf( "********  MUST try a direct load, DYLD*/LD* are null  ...\n");
    
    //  MUST use a different environment variable name ...
    //  REXX_LIBRARY_PATH looks good
    
    const char *rexxPath = getenv("REXX_LIBRARY_PATH");
    printf( "********  REXX_LIBRARY_PATH '%s'\n", rexxPath );
    
    //  it will take a while, but the next mods will supprt multiple rexxPath entries
    
    if ( rexxPath )
    {
        snprintf(nameBuffer, sizeof(nameBuffer), "%s/%s%s%s", rexxPath,
            CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX ) ;
        libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
        if ( libraryHandle )
        {
            return true;
        }
    }
    
    //  pretty useless on APPLE, /usr/lib is hidden for the finder and not writeabale
    snprintf(nameBuffer, sizeof(nameBuffer), "/usr/lib/%s%s%s", CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX ) ;
    libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
    if ( libraryHandle )
    {
        return true;
    }
    
    return false;    // load failed
    

    }

    consider the ticket closed...
    thank You

    here are the results ...
    [enrico@enrico-mbp enigma-machine]$rexx enigma
    ** trying a generic load ...

    enigma Result :
    enigma plainText : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    enigma ciphrText : 'BJELRQZVJWARXSNBXORSTNCFME'
    [enrico@enrico-mbp enigma-machine]$

    [enrico@enrico-mbp enigma-machine]$./enigma.rex
    * trying a generic load ...
    * MUST try a direct load, DYLD/LD are null ...
    ** REXX_LIBRARY_PATH '/opt/local/lib'

    enigma Result :
    enigma plainText : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    enigma ciphrText : 'BJELRQZVJWARXSNBXORSTNCFME'
    [enrico@enrico-mbp enigma-machine]$

     
  • Enrico Sorichetti

    as promised here is the same function dealing with multiple libs in te REXX_LIBRARY_PATH

    bool SysLibrary::load(
        const char *name)
    /******************************************************************************/
    /* Function:  Load a named library, returning success/failure flag            */
    /******************************************************************************/
    {
        char nameBuffer[PC_PATH_MAX+PC_NAME_MAX];
    
        if (strlen(name) > PC_NAME_MAX )
        {
            return false;
        }
    
        // printf( "********  trying a generic load ...\n" );
        // since APPLE is smart it recognizes that the head of the chain
        // when using rexx <somename> is a program
        // and the DYLD*/LD* variables are valid
        // using ./<somename>.rex, APPLE flags the head as a script,
        // which invalidates the the DYLD*/LD* variables
    
        snprintf(nameBuffer, sizeof(nameBuffer), "%s%s%s",
            CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX );
        libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
        if ( libraryHandle )
        {
            return true;     // loaded successfully
        }
    
        //  printf( "********  MUST try a direct load, DYLD*/LD* are null\n");
        //  MUST use a different environment variable name ...
        //  REXX_LIBRARY_PATH looks good
    
        const char *rexxLibraryPath = getenv("REXX_LIBRARY_PATH");
        //  printf( "********  REXX_LIBRARY_PATH '%s'\n", rexxLibraryPath );
    
        if ( rexxLibraryPath )
        {
            char buffr[PC_NAME_MAX];
            int  bufsz;
    
            const char *start = rexxLibraryPath;
            const char *limit;
    
            while ( ( limit = strchr(start, ':') ) != NULL )
            {
                bufsz = snprintf( buffr, sizeof(buffr), "%.*s", (int)(limit - start), start);
                printf("******** (%d) '%s'\n", bufsz, buffr );
                start = limit + 1;
                snprintf(nameBuffer, sizeof(nameBuffer), "%s/%s%s%s", buffr,
                    CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX ) ;
                libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
                if ( libraryHandle )
                {
                    return true;
                }
            }
    
            //  the last buffer has to dealt with outside of the loop
            bufsz = snprintf( buffr, sizeof(buffr), "%s", start );
            printf("******** (%d) '%s'\n", bufsz, buffr );
    
            snprintf(nameBuffer, sizeof(nameBuffer), "%s/%s%s%s", buffr,
                CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX ) ;
            libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
            if ( libraryHandle )
            {
                return true;
            }
        }
    
        //  pretty useless on APPLE, /usr/lib is hidden and not writeabale
        snprintf(nameBuffer, sizeof(nameBuffer), "/usr/lib/%s%s%s",
            CMAKE_SHARED_LIBRARY_PREFIX, name, CMAKE_SHARED_LIBRARY_SUFFIX ) ;
        libraryHandle = dlopen(nameBuffer, RTLD_LAZY);
        if ( libraryHandle )
        {
            return true;
        }
    
        return false;    // load failed
    }
    
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB