Problems getting PERL modules installed on LEDE

I'm having problems getting several PERL modules installed on LEDE.

The module base of LEDE is missing several modules needed to run FHEM functions.

Currently i am having problems with Text::Iconv, but the SSL modules of PERL are also affected and not possible to install through CPAN.

Since the modules are not provided by LEDE, it is required to use CPAN to install them.

But also the development package of PERL, perlbase-devel seems to be incomplete, since gcc can't find the needed config.h of PERL.

Please advice on how to proceed to get those PERL modules up and running.

I have attached my unsuccessful run of installing Text::Iconv through CPAN on LEDE:

==========
root@LEDE:/usr/lib/perl5/5.22/XML/Simple# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.11)
Enter 'h' for help.

cpan[1]> install Text::Iconv
Reading '/root/.cpan/Metadata'
Database was generated on Fri, 05 May 2017 22:54:22 GMT
Fetching with LWP:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Fri, 02 Jun 2017 17:17:03 GMT
.............
New CPAN.pm version (v2.16) available.
[Currently running version is v2.11]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.

...............................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Running install for module 'Text::Iconv'
Fetching with LWP:
http://www.cpan.org/authors/id/M/MP/MPIOTR/Text-Iconv-1.7.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/M/MP/MPIOTR/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/M/MP/MPIOTR/Text-Iconv-1.7.tar.gz ok
Scanning cache /root/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring M/MP/MPIOTR/Text-Iconv-1.7.tar.gz with Makefile.PL
Checking for iconv ... ok (iconv apparently in libc)

NOTE: If you have multiple iconv implementations installed, you might
want to make sure that I've found the one you want to use.
If necessary, you can explicitly specify paths like this:

  /usr/bin/perl5.22.1 Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Text::Iconv
Writing MYMETA.yml and MYMETA.json
MPIOTR/Text-Iconv-1.7.tar.gz
/usr/bin/perl5.22.1 Makefile.PL -- OK
Running make for M/MP/MPIOTR/Text-Iconv-1.7.tar.gz
cp Iconv.pm blib/lib/Text/Iconv.pm
AutoSplitting blib/lib/Text/Iconv.pm (blib/lib/auto/Text/Iconv)
Running Mkbootstrap for Text::Iconv ()
chmod 644 "Iconv.bs"
"/usr/bin/perl5.22.1" "/usr/lib/perl5/5.22/ExtUtils/xsubpp" -typemap "/usr/lib/perl5/5.22/ExtUtils/typemap" -typemap "typemap" Iconv.xs > Iconv.xsc && mv Iconv.xsc Iconv.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Os -pipe -mcpu=cortex-a53 -mfpu=neon-vfpv4 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -I/build/lede-17.01/slaves/phase2/arm_cortex-a53_neon-vfpv4/build/sdk/staging_dir/target-arm_cortex-a53+neon-vfpv4_musl-1.1.16_eabi/usr/include -I/build/lede-17.01/slaves/phase2/arm_cortex-a53_neon-vfpv4/build/sdk/staging_dir/target-arm_cortex-a53+neon-vfpv4_musl-1.1.16_eabi/include -I/build/lede-17.01/slaves/phase2/arm_cortex-a53_neon-vfpv4/build/sdk/staging_dir/toolchain-arm_cortex-a53+neon-vfpv4_gcc-5.4.0_musl-1.1.16_eabi/usr/include -I/build/lede-17.01/slaves/phase2/arm_cortex-a53_neon-vfpv4/build/sdk/staging_dir/toolchain-arm_cortex-a53+neon-vfpv4_gcc-5.4.0_musl-1.1.16_eabi/include/fortify -I/build/lede-17.01/slaves/phase2/arm_cortex-a53_neon-vfpv4/build/sdk/staging_dir/toolchain-arm_cortex-a53+neon-vfpv4_gcc-5.4.0_musl-1.1.16_eabi/include -O2 -DVERSION="1.7" -DXS_VERSION="1.7" -fPIC "-I/usr/lib/perl5/5.22/CORE" Iconv.c
In file included from Iconv.xs:9:0:
/usr/lib/perl5/5.22/CORE/perl.h:28:23: fatal error: config.h: No such file or directory
compilation terminated.
make: *** [Makefile:309: Iconv.o] Error 1
MPIOTR/Text-Iconv-1.7.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
MPIOTR/Text-Iconv-1.7.tar.gz : make NO

Can anyone help me what to do? How do i get a working perlbase-devel?

As i already stated, this also affects the SSL-networking of PERL on LEDE...

Found a solution to get perl fully running by myself. Thread can be closed.

Once again.
Share your solution.

Sure, i will repeat it here:

It was for me totally impossible without further directions from someone who is responsible for the perl modules on LEDE to set up any environment to build them correctly.

You have problems with:

  • musl: means you can not use binary modules from other linux distros which don't use musl and i found none except LEDE that uses musl.

  • incomplete perlbase-devel: means you can not compile perl modules on the machine itself; providing these from a new compiled perl source is also impossible; see next point.

  • GCC vs CCACHE; for perl on LEDE ccache was used as C-compiler. Modules need the exact same compiler environment as was used to compile perl itself. So it is impossible to add gcc compiled modules and gcc is the only compiler provided by LEDE.

  • Cross-Compiling: not sure how that would work, since missing modules are built on the running system through CPAN which would mean setting up a cross compile build environment for LEDE and for CPAN. Not sure if this is even possible with CPAN since it does a lot of tests with a built component within the running perl environment.

So i went another route.

I created what is called "DebianWRT" on the web:

  • install LEDE and use it as a base system with all needed kernel modules and software to access hardware and do the routing part

  • use debootstrap to install a debian-system in a fresh directory and chroot to it. Install PERL and FHEM to the chroot environment. Debian PERL provides all missing PERL modules.