Linking with versioned shared library in Android NDK

后端 未结 3 1980
我在风中等你
我在风中等你 2021-02-04 18:57

I am trying to load two shared libraries in my Android application through the loadLibrary call:

System.loadLibrary(\"mywrapper\");
System.loadLibra         


        
3条回答
  •  死守一世寂寞
    2021-02-04 19:25

    Year 2014 and still no support for versioned shared libs. So I made a script to patch SONAME. Just point the script to input dir where all versioned libs placed. Then check output dir "unver".

    #!/bin/bash
    
    DIR="$1"
    
    if [ "$DIR" == "" ]; then
        echo "Usage: fix-soname.sh "
        exit
    fi
    
    if [ ! -d $DIR ]; then
        echo "Not found: $DIR"
        exit
    fi
    
    OUT="$DIR/unver"
    echo "Input=$DIR"
    echo "Output=$OUT"
    
    CWD=$(pwd)
    cd $DIR
    
    # prep dirs
    mkdir -p $OUT
    rm -f -R $OUT/*
    
    # rename libs and copy to out dir
    find "$DIR" -type f -name '*.so*' | while read FILE; do
    
        NAME=$(basename "$FILE")
        SONAME=$NAME
    
        while read SYMLINK; do
            X=$(basename "$SYMLINK")
            #echo "$X (${#X}) -> $NAME (${#NAME})"
            if [ "${#X}" -lt "${#SONAME}" ]; then
                SONAME=$X
            fi
    done< $SONEW ($LDIFF)"
                rpl -R -e "$SONAME" "$SONEW" $OUT
            fi
        fi
    done
    
    cd $CWD
    

提交回复
热议问题