弁財天
ゴフマン「専門家を信じるのではなく、自分自身で考えて判断せよ」
ゴフマン「専門家を信じるのではなく、自分自身で考えて判断せよ」
これね。
perlandroid - search.cpan.org
なんでも最新版が好きなのでperl-5.27.5をビルドしてみる。
ANDROID_NDK=/home/hoge/Android/android-ndk-r15c TARGETARCH=aarch64-linux-android export ANDROID_TOOLCHAIN=/home/hoge/Android/zf4-toolchain-$TARGETARCH export SYSROOT=$ANDROID_TOOLCHAIN/sysroot # --system=`uname | tr '[A-Z]' '[a-z]'`-x86_64 \ $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \ --platform=android-24 \ --install-dir=$ANDROID_TOOLCHAIN \ --toolchain=$TARGETARCH-4.9
android NDK - make standalone toolchain fails
Unsupported platform: CYGWIN_NT-10.0-WOW ERROR: Failed to create toolchain.Win10のCygwin32環境は未サポートw
## COMMAND: python /home/hoge/src/android-ndk-r16-beta2/build/tools/make_standalone_toolchain.py --arch arm --api 24 --stl gnustl --install-dir=/home/hoge/src/zf4-toolchain-arm-linux-androideabi /home/hoge/src/android-ndk-r16-beta2/build/tools/ndk-common.sh: line 122: python: command not found ERROR: Failed to create toolchain.
## COMMAND: python /home/hoge/src/android-ndk-r16-beta2/build/tools/make_standalone_toolchain.py --arch arm --api 24 --stl gnustl --install-dir=/home/hoge/src/zf4-toolchain-arm-linux-androideabi Unsupported platform: CYGWIN_NT-10.0 ERROR: Failed to create toolchain.Win10のCygwin64環境も未サポートww
adbとsshを使ってクロスコンパイルする方法が書いてある。 adbはsuを使ってるのでnonroot環境では断念。
qiita.com→パスワードなしでscp
(2) sshしたいサーバー側に公開鍵(public key)を覚えさせる。パスワードなしてsshでコマンド実行できることを確認。
$ ssh-copy-id -i ~/.ssh/id_rsa.pub <user name>@<ip address>:
SSHelper Version 10.3 Copyright 2017, P. Lutus Default password is "admin" (recommend: change it)ビルド中に何度もsshが呼び出され実行するたびに表示されるw。
TARGETARCH=aarch64-linux-android TARGETDIR=/data/data/com.arachnoid.sshelper/home/perl SYSROOT=/home/hoge/Android/zf4-toolchain-aarch64-linux-android/sysroot export PATH=/home/ugya/Android/zf4-toolchain-aarch64-linux-android/bin:$PATH TARGETHOST=192.168.x.x TARGETUSER=android TARGETPORT=2222 ./Configure -A ccflags=-fPIC -A ldflags="-rdynamic -pie" -des -Dusedevel -Dusecrosscompile -Dtargetrun=ssh -Dcc=${TARGETARCH}-gcc -Dsysroot=$SYSROOT -Dtargetdir=$TARGETDIR -Dtargethost="$TARGETHOST" -Dtargetuser=$TARGETUSER -Dtargetport=$TARGETPORT
nonrootな環境に導入を試みるw。更新可能なディレクトリは、/sdcard/か、/data/data/com.arachnoid.sshelper/しかない。 /data/local/tmpなどはnonrootなので更新不可。 /sdcardはVFATなのでファイルにシンボリックリンクや実行権限をつけることができない。 なのでTARGETDIRは/data/data/com.arachnoid.sshelper/の下だけになってしまう。
aarch64-linux-android-gcc -c -DPERL_CORE --sysroot=/home/hoge/Android/zf4-toolchain-aarch64-linux-android/sysroot -fPIC -fwrapv -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror=declaration-after-statement -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings locale.c locale.c: In function 'S_new_ctype': locale.c:453:5: error: 'PERL_ARGS_ASSERT_NEW_CTYPE' undeclared (first use in this function) PERL_ARGS_ASSERT_NEW_CTYPE;perl-5.27.5はPERL_ARGS_ASSERT_NEW_CTYPE問題でコンパイル不可。 perl-5.27.5は諦めてw、perl-5.26.1にダウングレードw。だめですなぁ。make testが失敗して進まない。
Cross-compiling perlを使うのか。
make-standalone-toolchain.shで32ビットi686アーキテクチャのandroid-21のsysrootを作成。 こういうのをtoolchainて言うの?
#!/bin/sh B=/somewhere/ZenPhone2 ANDROID_NDK=${B}/android-ndk-r10d TARGETARCH=x86 #TARGET_TOOLCHAIN=x86_64-4.9 # x86_64はダメだったw TARGET_TOOLCHAIN=x86-4.9 ANDROID_TOOLCHAIN=${B}/ZenPhone2-toolchain-$TARGETARCH SYSROOT=$ANDROID_TOOLCHAIN/sysroot $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \ --platform=android-21 \ --install-dir=$ANDROID_TOOLCHAIN \ --system=linux-x86_64 \ --toolchain=$TARGET_TOOLCHAIN
Host system 'linux-x86' is not supported by the source NDK! #128
ターゲットはスマホのことで、ホストはクロスコンパイルする環境のことらすい。
だからといってlinux-x86_64 を指定する理由がわからない。イミフ
PATHに$ANDROID_TOOLCHAIN/binを追加。
TARGETDIRにはadb shellが書き込めるスマホのディレクトリを指定する。
/mnt/sdcardでは「chmod 755 a.out」できない。FATだから?
shell@Z00A:/ $ ls -l /mnt/sdcard lrwxrwxrwx root root 2015-05-16 06:12 sdcard -> /storage/emulated/legacy shell@Z00A:/ $
/storage/emulated/legacy て何?w
いろいろ理由があるのだろうけど、どこに配置するのが適当なのかよくわからないw
chmod 775 /data
chmod 775 /data/local
にして、
root@Z00A:/ # ls -ld data drwxrwx--x system system 2015-05-13 11:09 data root@Z00A:/ # chmod 775 data root@Z00A:/ # ls -ld data drwxrwxr-x system system 2015-05-13 11:09 data root@Z00A:/ #/data/local当たりが適当かも?
TARGETDIR=/data/local/tmp/perl
に変更。
「rm: 書き込み保護されたファイル 通常ファイル `output.stdout' を削除しますか?」がうるさいので
perl-5.21.11/Cross/run-adb-shellを手メンテしてrmに-fを追加。
rm -f output.stdout output.stderr output.status 2>/dev/null
rm -f output.stdout output.stderr output.status
w
TARGETARCH=x86 ANDROID_TOOLCHAIN=/somewhere/ZenPhone2/ZenPhone2-toolchain-${TARGETARCH} PATH=${ANDROID_TOOLCHAIN}/bin:$PATH export PATH
#!/bin/sh TARGETARCH=i686-linux-android SYSROOT=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot TARGETDIR=/data/local/tmp/perl DEVICE=F4AZFG08F222 ./Configure -des -Dusedevel -Dusecrosscompile -Dtargetrun=adb \ -Dcc=$TARGETARCH-gcc \ -Dldflags="-pie -fPIE" \ -Dsysroot=$SYSROOT \ -Dtargetdir=$TARGETDIR \ -Dtargethost=$DEVICE
shell@Z00A:/data/local/tmp/perl64 $ ./a.out /system/bin/sh: ./a.out: No such file or directory 1|shell@Z00A:/data/local/tmp/perl64 $TARGETARCH=x86_64-linux-android だとa.outはできるが
aix dragonfly irix_4 nonstopux stellar aix_3 dynix irix_5 openbsd sunos_4_0 aix_4 dynixptx irix_6 opus sunos_4_1 altos486 epix irix_6_0 os2 super-ux amigaos esix4 irix_6_1 os390 svr4 atheos fps isc os400 svr5 aux_3 freebsd isc_2 posix-bc ti1500 bitrig freemint linux-android powerux ultrix_4 bsdos genix linux qnx umips catamount gnu lynxos riscos unicos convexos gnukfreebsd midnightbsd sco unicosmk cxux gnuknetbsd mips sco_2_3_0 unisysdynix cygwin greenhills mirbsd sco_2_3_1 utekv darwin haiku mpc sco_2_3_2 uwin dcosx hpux ncr_tower sco_2_3_3 vos dec_osf i386 netbsd sco_2_3_4 dos_djgpp interix newsos4 solaris_2 Which of these apply, if any? [linux-android] Updating makefile... Now you must run 'make'. If you compile perl5 on a different machine or from a different object directory, copy the Policy.sh file from this object directory to the new one before you run Configure -- this will help you with most of the policy defaults. [hoge@localhost perl-5.21.11]$
make test
Now you're ready to run make and make test! As a final word of warning, if you're using adb, make test may appear to hang; this is because it doesn't output anything until it finishes running all tests. You can check its progress by logging into the device, moving to $TARGETDIR, and looking at the file output.stdout../TESTはハングアップしてるのではない。裏で$TARGETDIR/output.stdoutにテスト結果を書き出してるのだとーか。
[hoge@localhost perl-5.21.11]$ make test /usr/bin/ln -s /somewhere/ZenPhone2/perl-5.21.11/host/generate_uudmap generate_uudmap ./miniperl -Ilib make_ext.pl cpan/Archive-Tar/pm_to_blib MAKE="make" LIBPERL_A=libperl.a make[1]: ディレクトリ `/somewhere/ZenPhone2/perl-5.21.11/cpan/Archive-Tar' に入ります make[1]: ディレクトリ `/somewhere/ZenPhone2/perl-5.21.11/cpan/Archive-Tar' から出ます ./miniperl -Ilib make_ext.pl dist/Attribute-Handlers/pm_to_blib MAKE="make" LIBPERL_A=libperl.a 略 /somewhere/ZenPhone2/perl-5.21.11/Cross/to-adb-push t/perl 3928 KB/s (1938176 bytes in 0.481s) /somewhere/ZenPhone2/perl-5.21.11/Cross/run-adb-shell -cwd /data/local/tmp/perl/t -env " LD_LIBRARY_PATH=/data/local/tmp/perl:/data/local/tmp/perl/lib:/data/local/tmp/perl/lib/auto:$LD_LIBRARY_PATH" ./TEST t/base/cond ................................................... ok t/base/if ..................................................... ok 略 Compilation failed in require at t/usage.t line 10. Can't load '../../lib/auto/POSIX/PL_POSIX.so' for module POSIX: dlopen failed: cannot locate symbol "ctermid" referenced by "PL_POSIX.so"... at ../../lib/XSLoader.pm line 75. at ../../lib/POSIX.pm line 36. Compilation failed in require at t/wrappers.t line 10. Can't load '../lib/auto/POSIX/PL_POSIX.so' for module POSIX: dlopen failed: cannot locate symbol "ctermid" referenced by "PL_POSIX.so"... at ../lib/XSLoader.pm line 75. at ../lib/POSIX.pm line 36. Compilation failed in require at ../lib/B/Deparse.t line 168. BEGIN failed--compilation aborted at ../lib/B/Deparse.t line 168. Number found where operator expected at ../lib/IPC/Cmd.pm line 601, near "POSIX::_exit 1" (Do you need to predeclare POSIX::_exit?) Bareword "POSIX::WNOHANG" not allowed while "strict subs" in use at ../lib/IPC/Cmd.pm line 487. syntax error at ../lib/IPC/Cmd.pm line 601, near "POSIX::_exit 1" BEGIN not safe after errors--compilation aborted at ../lib/IPC/Cmd.pm line 1458. Compilation failed in require at ../lib/ExtUtils/t/Embed.t line 14. BEGIN failed--compilation aborted at ../lib/ExtUtils/t/Embed.t line 14. Permission denied at ../lib/File/Copy.t line 160. # Looks like you planned 466 tests but ran 27. # Looks like your test exited with 13 just after 27. Failed 204 tests out of 2056, 90.08% okay. ### Since not all tests were successful, you may want to run some of ### them individually and examine any diagnostic messages they produce. ### See the INSTALL document's section on "make test". ### You have a good chance to get more information by running ### ./perl harness ### in the 't' directory since most (>=80%) of the tests succeeded. ### You may have to set your dynamic library search path, ### LD_LIBRARY_PATH, to point to the build directory: ### setenv LD_LIBRARY_PATH `pwd`; cd t; ./perl harness ### LD_LIBRARY_PATH=`pwd`; export LD_LIBRARY_PATH; cd t; ./perl harness ### export LD_LIBRARY_PATH=`pwd`; cd t; ./perl harness ### for csh-style shells, like tcsh; or for traditional/modern ### Bourne-style shells, like bash, ksh, and zsh, respectively. make: *** [test] エラー 1 [hoge@localhost perl-5.21.11]$お、何か終わった。
127|root@Z00A:/data/local/tmp/perl # ./perl -V Can't locate Config.pm in @INC (you may need to install the Config module) (@INC contains: /data/local/tmp/lib/perl5/site_perl/5.21.11/linux-android /data/local/tmp/lib/perl5/site_perl/5.21.11 /data/local/tmp/lib/perl5/5.21.11/linux-android /data/local/tmp/lib/perl5/5.21.11 .). BEGIN failed--compilation aborted. 2|root@Z00A:/data/local/tmp/perl #
しょーがねーなー。
perl-5.21.11/lib/*のしたをtarしてadb push
/data/local/tmp/lib/perl5/5.21.11に展開w
127|shell@Z00A:/data/local/tmp/perl $ ./perl -V Summary of my perl5 (revision 5 version 21 subversion 11) configuration: Platform: osname=android, osvers=5.0, archname=linux-android uname='linux hp6730s.localdomain 4.0.2-1.el7.elrepo.x86_64 #1 smp thu may 7 12:20:46 edt 2015 x86_64 x86_64 x86_64 gnulinux ' config_args='-des -Dusedevel -Dusecrosscompile -Dtargetrun=adb -Dcc=i686-linux-android-gcc -Dldflags=-pie -fPIE -Dsysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot -Dtargetdir=/data/local/tmp/perl -Dtargethost=F4AZFG08F222' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='i686-linux-android-gcc', ccflags ='--sysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2', optimize='-O2', cppflags='--sysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot --sysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot' ccversion='', gccversion='4.9 20140827 (prerelease)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, doublekind=3 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8, longdblkind=0 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=4, prototype=define Linker and Libraries: ld='i686-linux-android-gcc', ldflags ='-pie -fPIE --sysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot' libpth=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/bin/../lib/gcc/i686-linux-android/4.9/include-fixed /somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot/usr/lib /system/lib /vendor/lib /system/lib /vendor/lib /system/lib /vendor/lib /system/lib /vendor/lib /system/lib /vendor/lib /system/lib /vendor/lib libs=-ldl -lm -lc perllibs=-ldl -lm -lc libc=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot/usr/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC --sysroot=/somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot', lddlflags='-shared -O2 --sysroot /somewhere/ZenPhone2/ZenPhone2-toolchain-x86/sysroot' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under android Compiled at May 14 2015 14:53:07 @INC: /data/local/tmp/lib/perl5/site_perl/5.21.11/linux-android /data/local/tmp/lib/perl5/site_perl/5.21.11 /data/local/tmp/lib/perl5/5.21.11/linux-android /data/local/tmp/lib/perl5/5.21.11 . shell@Z00A:/data/local/tmp/perl $ ./perl -v This is perl 5, version 21, subversion 11 (v5.21.11) built for linux-android Copyright 1987-2015, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. shell@Z00A:/data/local/tmp/perl $
でもCPANでモジュールの追加とかできないよな。
How do I install Perl Modules on Scripting Layer for Android (SL4A)?
導入に成功してる環境のライブラリーを見つけてadb pushしてしまえとw
AndroidのNDKおもろいわー。LinuxのソースtarボールをconfigureしてAndroid用にビルドできる。ロードモジュールをadb pushしてスマホをいつも使ってるLinuxみたいにできるとこがいーね。
Bonaponta in Android 2015年5月14日 午後 05:28 JST
Tags: zenfone