develooper Front page | perl.perl5.porters | Postings from September 2013

Re: Question on porting perl 5.16 to Android (no /bin/sh)

Thread Previous | Thread Next
From:
Ben Greear
Date:
September 5, 2013 16:23
Subject:
Re: Question on porting perl 5.16 to Android (no /bin/sh)
Message ID:
5228B009.7080902@candelatech.com
On 09/05/2013 08:52 AM, Brian Fraser wrote:
> On Thu, Sep 5, 2013 at 2:23 AM, Ben Greear <greearb@candelatech.com <mailto:greearb@candelatech.com>> wrote:

>     A simple test to make sure it handles `complex shell comman` works, but in a more advanced
>     script, I'm getting this error:
>
>     Can't load '/data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/auto/Fcntl/Perl___Fcntl.so' for module Fcntl: dlopen failed: cannot
>     locate symbol "Perl_stack_grow" referenced by "Perl_Fcntl.so"... at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/__XSLoader.pm line 69.
>       at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/Fcntl.pm line 66.
>     Compilation failed in require at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/POSIX.pm line 11.
>     BEGIN failed--compilation aborted at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/POSIX.pm line 17.
>
>
> Stab in the dark, did you perhaps forget to run the
>
> perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh

That was not the problem.

>
> Line after configure but before running make?
>
> If not, I'm a tad stumped. You can try setting LD_LIBRARY_PATH to something relevant, like pointing at the CORE directory, or try building a shared perl (more
> on that in a moment)
>
>
>     I noticed that there is a ...../CORE/libperl.a file, but there is no libperl.so anywhere to be found
>     in the install directory.
>
>     On the older perl I tried from the perldroid project there was a libperl.so in the CORE directory.
>
>     Do I actually need the libperl.so to be created somehow or is that symbol supposed
>     to be located elsewhere?
>
>
> By default, perl builds a static perl, so this should be fine, but you can try building a shared libperl by running Configure with
>
> -Uuserelocatableinc -Duseshrplib
> And checking if that works any differently? You'll have to set both LD_LIBRARY_PATH and PERL5LIB to use that, though.

Building shared did fix the problem.  I've yet more testing to complete, but so far
it seems OK.  In case anyone else tries this, here are my notes.  I think these
are free of typos, but I'll need to do another full build from clean repository
to know for sure.



# Install latest android ndk and sdk.  I put them in ~/android
# and also created a stand-alone tool-chain called ~/my-android-toolchain-8
# I am compiling on an x86-64 machine (Fedora 17).
# My specific Nexus-4 DEVICE ID is used below.  You would use your own
# or possibly an emulator would also work.

export ANDROID_NDK=$HOME/android/android-ndk-r9
export ANDROID_SDK=$HOME/android/android-sdk-linux
export ANDROID_TOOLCHAIN=$HOME/my-android-toolchain-8
export PATH="$ANDROID_SDK/platform-tools:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH"

# Turn on USB debugging in developer-options on phone, then:
adb devices
export DEVICE=04dba74c5cde4be7

export TARGETDIR=/data/data/candela.lanforge/local/
adb -s $DEVICE shell "echo sh -c '\"mkdir -p $TARGETDIR\"' | su --"
adb -s $DEVICE shell "echo sh -c '\"chmod 777 $TARGETDIR\"' | su --"
adb -s $DEVICE pull /system/lib /tmp/tmpandroidlib

rm -f config.sh
rm -f Policy.sh
LF_PREFIX=/data/data/candela.lanforge/local
./Configure -des -U userelocatableinc -A undef:versiononly -U versiononly -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc -Duseshrplib 
-Dprefix=${LF_PREFIX} -Dtargethost=$DEVICE -Dsysroot=$ANDROID_TOOLCHAIN/sysroot -Dtargetdir=$TARGETDIR

perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh
make -j30
# This next step may take a very long time.
#make test

# Comment out the manpages install, or just ignore the error, it
# does not seem to be a problem.
LF_PERL_INST=/tmp/android-perl
rm -fr /tmp/android-perl*
make DESTDIR=${LF_PERL_INST} install

#Then copy the perl installed into /tmp/android-perl to your device

# LANforge related packaging step.

rm -fr ~/perl-arm-5.18-lf
mkdir -p ~/perl-arm-5.18-lf
mv ${LF_PERL_INST}/${LF_PREFIX}/* ~/perl-arm-5.18-lf

# NOTE:  You have to set LD_LIBRARY_PATH and PERL5LIB appropriately before using
# perl on the Android device, for instance

LF_HOME=/data/data/candela.lanforge
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${LF_HOME}:${LF_HOME}/local/lib:${LF_HOME}/local/lib/perl5/5.18.0/linux-androideabi/CORE
PERL5LIB=${LF_HOME}/local/lib/perl5/5.18.0/linux-androideabi:${LF_HOME}/local/lib/perl5/5.18.0/


Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About