in reply to Re^2: How To Link -lperl to Extensions During Build
in thread How To Link -lperl to Extensions During Build

I think you will have to show some of your output how -Aldflags fails, and maybe also how installing modules fails after you've compiled your Perl.

Replies are listed 'Best First'.
Re^4: How To Link -lperl to Extensions During Build
by cyd (Novice) on May 11, 2015 at 01:16 UTC

    Here's how the extensions build fails. WARNING: lengthy output follows

    make[1]: Leaving directory `/bld/perl/perl-5.20.2/dist/threads-shared' LD_LIBRARY_PATH=/bld/perl/perl\-5.20.2:/data/data/jackpal.androidterm/ +kbox2/lib ./perl -Ilib -f pod/buildtoc -q Can't load 'lib/5.20.2/armv7l-linux-android/auto/re/PL_re.so' for modu +le re: dlopen failed: cannot locate symbol "Perl_bytes_to_utf8" refer +enced by "PL_re.so"... at lib/5.20.2/armv7l-linux-android/DynaLoader. +pm line 218. at lib/5.20.2/Text/Wrap.pm line 58. Compilation failed in require at lib/5.20.2/Text/Wrap.pm line 58. BEGIN failed--compilation aborted at lib/5.20.2/Text/Wrap.pm line 58. Compilation failed in require at pod/buildtoc line 7. BEGIN failed--compilation aborted at pod/buildtoc line 7. make: *** [pod/perltoc.pod] Error 2

    Here's how the build fails with -Aldflags

    se which C compiler? [gcc --sysroot=/usr/gcc-4.9.2/sysroot] /usr/gcc-4.9.2/bin/ld: cannot find -lperl collect2: error: ld returned 1 exit status Uh-oh, the C compiler 'gcc --sysroot=/usr/gcc-4.9.2/sysroot' doesn't s +eem to be working. /usr/gcc-4.9.2/bin/ld: cannot find -lperl collect2: error: ld returned 1 exit status Uh-oh, the C compiler 'gcc --sysroot=/usr/gcc-4.9.2/sysroot' doesn't s +eem to be working. You need to find a working C compiler. Either (purchase and) install the C compiler supplied by your OS vendo +r, or for a free C compiler try http://gcc.gnu.org/ I cannot continue any further, aborting.

    And if I copy -lperl to $SYSROOT

    Use which C compiler? [gcc --sysroot=/usr/gcc-4.9.2/sysroot] /usr/gcc-4.9.2/bin/ld: warning: libm.so, needed by /usr/gcc-4.9.2/sysr +oot/usr/lib/libperl.so, not found (try using -rpath or -rpath-link) /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `log +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sqr +t' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `cei +l' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `flo +or' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sca +lbnl' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `mod +f' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `fmo +d' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `cos +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sin +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `ata +n2' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `pow +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `exp +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `ilo +gbl' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `fre +xp' collect2: error: ld returned 1 exit status Uh-oh, the C compiler 'gcc --sysroot=/usr/gcc-4.9.2/sysroot' doesn't s +eem to be working. /usr/gcc-4.9.2/bin/ld: warning: libm.so, needed by /usr/gcc-4.9.2/sysr +oot/usr/lib/libperl.so, not found (try using -rpath or -rpath-link) /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `log +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sqr +t' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `cei +l' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `flo +or' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sca +lbnl' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `mod +f' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `fmo +d' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `cos +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `sin +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `ata +n2' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `pow +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `exp +' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `ilo +gbl' /usr/gcc-4.9.2/sysroot/usr/lib/libperl.so: undefined reference to `fre +xp' collect2: error: ld returned 1 exit status Uh-oh, the C compiler 'gcc --sysroot=/usr/gcc-4.9.2/sysroot' doesn't s +eem to be working. You need to find a working C compiler. Either (purchase and) install the C compiler supplied by your OS vendo +r, or for a free C compiler try http://gcc.gnu.org/ I cannot continue any further, aborting.

      Hmm - it now slowly dawns on me that adding -lperl should only happen when compiling extensions instead of being a compiler flag when compiling Perl itself. Surprisingly, the INSTALL document for Perl doesn't mention any appropriate linker flags that would apply only to after perl.o has been built.

      As I've successfully built Perl (5.21.11, soon also 5.22.0-RC0) using cctools, my first suggestion would be to try the build using cctools instead of your compiler kit, just to see whether it is a problem with your build of Android or with the package or the environment. Slide 24 of this talk shows the command line I've used to compile Perl. Maybe that is already sufficient to make your compiler kit work with how Perl configures itself:

      sh ./Configure -Dprefix=/storage/sdcard0/perl -des -Dusedevel -Dprefix=/data/local/perl-5.21.11/ -Dsysroot=/data/data/com.pdaxrom.cctools/root/cctools -Alibpth="/system/lib /vendor/lib" -Dman1dir=none -Dman3dir=none -Dsite1man=none -Dsite3man=none -Dvendorman1=none -Dvendorman3=none -DNO_LOCALE

      Most likely, you will need to edit the -Dsysroot variable and likely you will want to set the prefix to something supported on your device.