I finally succeeded :-) My android test phone is old. I found the solution 
[here](https://stackoverflow.com/questions/27338318/cannot-load-library-reloc-library1285-cannot-locate-rand)
 Work with API level 19! 
    
    
    test.bin: 1 file pushed. 1.2 MB/s (142260 bytes in 0.109s)
    Hello World!
    
    
    Run

Cosmetic changes in sh script: 
    
    
    #!/bin/sh
    
    NIMSRC="https://github.com/nim-lang/Nim/archive/v0.19.4.zip";
    
NDKSRC="https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip";
    TESTCODE="/home/hdias/test.nim"
    APILEVEL=19
    CPU="arm"
    TMPDIR="/home/hdias/tmp"
    NIMCACHE="/home/hdias/.cache/nim"
    CLANG="armv7a-linux-androideabi$APILEVEL-clang"
    
    if ! [ -d $TMPDIR ]
    then
        mkdir $TMPDIR
    fi
    cd $TMPDIR
    
    cp $TESTCODE ./
    
    if [ -z $(ls -d1 Nim-*/) ]
    then
        wget $NIMSRC
        unzip $(ls -1 v*.zip)
    fi
    NIM=$(ls -d1 Nim-*/)
    NIM=$TMPDIR/${NIM::-1}
    
    if [ -z $(ls -d1 android-ndk-*/) ]
    then
        wget $NDKSRC
        unzip $(ls -1 android-ndk-*.zip)
    fi
    
    NDK=$(ls -d1 android-ndk-*/)
    NDK=$TMPDIR/${NDK::-1}
    
    NIMFILE=$(basename -- $TESTCODE)
    
    nim c --os:android --cpu=$CPU --os:android --compileOnly $NIMFILE
    
    FILENAME="${NIMFILE%.*}"
    
    $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$CLANG \
    -I$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
    -I$NIM/lib -fPIE -pie \
    -o $TMPDIR/$FILENAME.bin \
    $NIMCACHE/$FILENAME"_d"/$FILENAME.c $NIMCACHE/$FILENAME"_d"/stdlib_system.c
    
    if [ -z $(adb get-state) ]
    then
        echo "Error!"
        exit
    fi
    
    adb push test.bin /data/local/tmp/test.bin
    adb shell /data/local/tmp/test.bin
    
    
    Run

Reply via email to