Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How To Link -lperl to Extensions During Build

by Corion (Patriarch)
on May 09, 2015 at 21:55 UTC ( [id://1126208]=note: print w/replies, xml ) Need Help??


in reply to How To Link -lperl to Extensions During Build

If you really, really want to go that way, I think the -Dldflags or -Aldflags (for -Append) options to ./Configure are the way. But are you sure you don't want to use the cctools? They come with a shell window and make, gcc and all the shell utilities and at least I didn't need to jump through too many hoops when compiling Perl for Android.

The configure command I use to compile Perl 5.21.11 on Android is:

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

Also you might want to take a look at App::staticperl, which will try to compile a perl with all libraries linked statically into it.

Replies are listed 'Best First'.
Re^2: How To Link -lperl to Extensions During Build
by cyd (Novice) on May 09, 2015 at 23:17 UTC

    KBOX is a shell environment that emulates a Linux filesystem...make, gcc and a ton of other utilites are included.

    Its one quirk is that it only supports dynamic linking to libc...that plus Android's broken linker means any ext that uses symbols from libperl.so needs to be linked to it.

    Will using -Aldflags propagate down to the part of the build where extensions are compiled?

Re^2: How To Link -lperl to Extensions During Build
by cyd (Novice) on May 10, 2015 at 02:14 UTC
    Additionally, -Aldflags doesn't seem to work...

      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.

        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.
Re^2: How To Link -lperl to Extensions During Build
by cyd (Novice) on May 11, 2015 at 11:37 UTC

    Hopefully this post will show up in the thread this time...having a bit of difficulty posting via tablet

    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

    Use 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126208]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-20 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found