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
Ben Greear
September 5, 2013 16:23
Re: Question on porting perl 5.16 to Android (no /bin/sh)
Message ID:
On 09/05/2013 08:52 AM, Brian Fraser wrote:
> On Thu, Sep 5, 2013 at 2:23 AM, Ben Greear < <>> 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/' for module Fcntl: dlopen failed: cannot
>     locate symbol "Perl_stack_grow" referenced by ""... at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/ line 69.
>       at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/ line 66.
>     Compilation failed in require at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/ line 11.
>     BEGIN failed--compilation aborted at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/ line 17.
> Stab in the dark, did you perhaps forget to run the
> perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}"

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 anywhere to be found
>     in the install directory.
>     On the older perl I tried from the perldroid project there was a in the CORE directory.
>     Do I actually need the 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
rm -f
./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'}"
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.
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



Ben Greear <>
Candela Technologies Inc

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About