Enabling PNG support while installing GD.pm in Perl - perl

I have already installed GD.pm. I want to make sure it supports PNG.
So to check that I do this:
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
no
As you see. It prints no.
Then I download the latest GD from CPAN with the following process:
> wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.53.tar.gz
> tar xvfz GD-2.53.tar.gz
> cd GD-2.44
> perl Makefile.PL
> make
> make test
> make install
I expect it to contain the line like this which is a hallmark of the installed PNG support:
Included Features: GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE
GD_PNG GD_GIF GD_GIFANIM GD_OPENPOLYGON GD_UNCLOSEDPOLY GD_ANIMGIF
GD_FTCIRCLE VERSION_33
But instead I got this only:
Included Features: GD_GIF GD_GIFANIM GD_OPENPOLYGON
I wasn't successful with this command either sudo perl Makefile.PL -options "JPEG,FT,PNG".
It didn't show GD_PNG.
What's the way to install GD.pm with PNG support?
I need it to run circos.
Update:
After installing libpng and rebuilding GD
$ brew update && brew upgrade
$ brew install gd
$ brew install libpng
$ sudo cpan
cpan > force install GD
as adviced, I got this error:
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
Can't load '/Library/Perl/5.16/darwin-thread-multi-2level/auto/GD/GD.bundle' for module GD: dlopen(/Library/Perl/5.16/darwin-thread-multi-2level/auto/GD/GD.bundle, 1): Library not loaded: libpng15.15.dylib
Referenced from: /usr/local/lib/libfreetype.6.dylib
Reason: image not found at /System/Library/Perl/5.16/darwin-thread-multi-2level/DynaLoader.pm line 194.
at -e line 1.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Update 2:
Finally I fixed the problem by doing this:
$ locate libpng15.15.dylib
/anaconda/lib/libpng15.15.dylib
/anaconda/pkgs/libpng-1.5.13-1/lib/libpng15.15.dylib
/opt/X11/lib/libpng15.15.dylib
/opt/local/lib/libpng15.15.dylib
$ ln -s /opt/X11/lib/libpng15.15.dylib /usr/local/lib/libpng15.15.dylib
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
yes

You need libraries as dependencies before making GD.pm. In this particular case libpng is obviously missing.
Because of that dependency, I recommend that you use package managers, not CPAN, if your perl is the one that comes with your OS:
MacPorts or homebrew for OS X
apt-get for Debian and Ubuntu.
yum for RHEL, Cent-OS.

Related

How can I install Net::SSLeay with perlbrew in macOS Catalina?

I am trying to install Net::SSLeay perl package on Mac OSX Catalina using perlbrew cpanm and failing due to openssl related issues.
I tried all of the bellow solutions to no avail:
cmake - osx/mac - openssl brew
https://gist.github.com/andyjack/7dd4d7b65d262b2a6e56
https://medium.com/#deepak.gulati/installing-net-ssleay-on-os-x-el-capitan-446c40cffeba
https://phillipadsmith.com/2016/03/Installing-Net-SSLeay-on-OS-X-El-Capitan.html
https://apple.stackexchange.com/questions/240589/crypt-ssleay-on-a-macbook
https://macosx.com/threads/howto-installing-openssl-and-the-ssl-perl-module-net-ssleay-pm.12075/
I have open ssl latest and added the suggested exports to my .zshrc
I added these to .zshrc:
# Warning: Refusing to link macOS-provided software: openssl#1.1
# If you need to have openssl#1.1 first in your PATH run:
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
# For compilers to find openssl#1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
# For pkg-config to find openssl#1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl#1.1/lib/pkgconfig"
the basic failure is:
cpanm (App::cpanminus) 1.7044 on perl 5.030001 built for darwin-2level
Work directory is /Users/<me>
/.cpanm/work/1583739797.88350
You have make /usr/bin/make
You have LWP 6.43
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
Searching Net::SSLeay () on cpanmetadb ...
--> Working on Net::SSLeay
Fetching http://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz
-> OK
Unpacking Net-SSLeay-1.88.tar.gz
Entering Net-SSLeay-1.88
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.34)
Configuring Net-SSLeay-1.88
Running Makefile.PL
Do you want to run external tests?
These tests *will* *fail* if you do not have network connectivity. [n] n
*** Found LibreSSL-2.8.3 installed in /usr
*** Be sure to use the same compiler and options to compile your OpenSSL, perl,
and Net::SSLeay. Mixing and matching compilers is not supported.
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Net::SSLeay
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0.60_01 ... Yes (1.302162)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.34)
Checking if you have MIME::Base64 0 ... Yes (3.15)
Building and testing Net-SSLeay-1.88
cp lib/Net/SSLeay.pm blib/lib/Net/SSLeay.pm
AutoSplitting blib/lib/Net/SSLeay.pm (blib/lib/auto/Net/SSLeay)
blib/lib/Net/SSLeay.pm: some names are not unique when truncated to 8 characters:
directory blib/lib/auto/Net/SSLeay:
do_https3.al, do_https2.al, do_https4.al, do_https.al truncate to do_https
do_httpx3.al, do_httpx2.al, do_httpx4.al truncate to do_httpx
get_https.al, get_https3.al, get_https4.al, get_http.al, get_http3.al, get_http4.al, get_httpx.al, get_httpx3.al, get_httpx4.al truncate to get_http
head_https.al, head_https3.al, head_https4.al, head_http.al, head_http3.al, head_http4.al, head_httpx.al, head_httpx3.al, head_httpx4.al truncate to head_htt
post_https.al, post_https3.al, post_https4.al, post_http.al, post_http3.al, post_http4.al, post_httpx.al, post_httpx3.al, post_httpx4.al truncate to post_htt
put_https.al, put_https3.al, put_https4.al, put_http.al, put_http3.al, put_http4.al, put_httpx.al, put_httpx3.al, put_httpx4.al truncate to put_http
ssl_read_all.al, ssl_read_until.al, ssl_read_CRLF.al truncate to ssl_read
ssl_write_all.al, ssl_write_CRLF.al truncate to ssl_writ
tcp_read_all.al, tcp_read_until.al, tcp_read_CRLF.al truncate to tcp_read
tcp_write_all.al, tcp_write_CRLF.al truncate to tcp_writ
cp lib/Net/SSLeay/Handle.pm blib/lib/Net/SSLeay/Handle.pm
cp lib/Net/SSLeay.pod blib/lib/Net/SSLeay.pod
Running Mkbootstrap for SSLeay ()
chmod 644 "SSLeay.bs"
"/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- SSLeay.bs blib/arch/auto/Net/SSLeay/SSLeay.bs 644
"/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/bin/perl" "/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/ExtUtils/xsubpp" -typemap '/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/ExtUtils/typemap' -typemap '/Users/<me>
/.cpanm/work/1583739797.88350/Net-SSLeay-1.88/typemap' SSLeay.xs > SSLeay.xsc
mv SSLeay.xsc SSLeay.c
cc -c -fno-common -DPERL_DARWIN -mmacosx-version-min=10.15 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV -O3 -DVERSION=\"1.88\" -DXS_VERSION=\"1.88\" "-I/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/darwin-2level/CORE" SSLeay.c
SSLeay.xs:163:10: fatal error: 'openssl/err.h' file not found
#include <openssl/err.h>
^~~~~~~~~~~~~~~
1 error generated.
make: *** [SSLeay.o] Error 1
-> FAIL Installing Net::SSLeay failed. See /Users/<me>
/.cpanm/work/1583739797.88350/build.log for details. Retry with --force to force install it.
Finally after much fiddling I found this post:
OSX Catalina work around
I uninstalled latest perlversion:
perlbrew uninstall perl-5.30.1
Then I ran this script
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "$0 is running from: $DIR"
# make this file's location working dir
cd "$(dirname "$0")"
v='perl-5.30.1'
perl_versions=$(perlbrew list)
echo "perl_versions $perl_versions"
if [[ "$perl_versions" == *"$v"* ]]; then
echo "$v is installed in perlbrew."
else
echo "$v is not!!! installed in perlbrew. installing ...."
perlbrew install perl-5.30.1 --notest --force
fi
current_perl_version=$(which perl)
echo "current_perl_version: $current_perl_version"
if [[ "$current_perl_version" == *"$v"* ]]; then
echo "$v is current version."
else
echo "$v is not current version."
perlbrew switch $v
fi
cpanm install --force Test::Block
cpanm install Try::Tiny
cpanm install YAML
cpanm install YAML::XS
cpanm install JSON
cpanm install JSON::MaybeXS
cpanm install HTTP::Request
cpanm install HTTP::Response
cpanm install HTTP::Daemon
cpanm install GD::Simple
cpanm install GD::Graph
cpanm install Data::HexDump::Range
cpanm install Proc::Daemon
cpanm install Test::Block
cpanm install Text::Colorizer
cpanm install Gzip::Faster
cpanm install IO::Socket::INET6
#export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
#export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
#export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
cpanm install DBI
#cpanm install Net::SSLeay
OPENSSL_PREFIX=/usr/local/opt/openssl#1.1 cpanm --interactive --verbose --force Net::SSLeay
cpanm install --force Cassandra::Client
cpanm install DBD::Cassandra
#cpanm install https://cpan.metacpan.org/authors/id/T/TV/TVDW/Cassandra-Client-0.16.tar.gz
cpanm install Proc::ProcessTable
cpanm install Kafka::Connection
During the Net::SSLeay installation I was prompted for manual confirmation for tests dependant on network connectivity and answered y. If anyone knows auto-approve in perlbrew please post a comment, A quick scower of perlbrew -h wasn't informative as to auto approve options at first glance.
I tried this on macOS Catalina (note my shell is bash and not the default zsh):
brew install openssl
\curl -L https://install.perlbrew.pl | bash
After perlbrew is installed, edit ~/.bash_profile :
source ~/perl5/perlbrew/etc/bashrc
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
Then save, and execute
$ source ~/.bash_profile
$ perlbrew install-cpanm
$ perlbrew install perl-5.30.1 --notest
$ perlbrew switch perl-5.30.1
$ cpanm Net::SSLeay
--> Working on Net::SSLeay
Fetching http://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz ... OK
Configuring Net-SSLeay-1.88 ... OK
Building and testing Net-SSLeay-1.88 ... OK
Successfully installed Net-SSLeay-1.88
1 distribution installed
So my guess would be that the issue is related to zsh, since I used bash and you used zsh.

Can't locate DBI.pm

I'm trying to launch this script:
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect( 'dbi:Oracle:host=lonlin2;sid=TIMFX1AD;port=1524','xbsesdbo','xbsesdbo123' ) || die ( $DBI::errstr . "\n" );
my $query= "SELECT * FROM product_elements WHERE element_id = 1001";
my $queryHandler= $dbh->prepare($query);
my $result= $queryHandler->execute();
open(fileHandler,"> note.txt");
print fileHandler "Risultato query: $result\n";
my $e= $dbh->disconnect();
close(fileHandler);
When I launch this script I receive this error:
Can't locate DBI.pm in #INC (#INC contains: /opt/perl_32/lib/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/5.8.3 /opt/perl_32/lib/site_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/site_perl/5.8.3 /opt/perl_32/lib/site_perl /opt/perl_32/lib/vendor_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/vendor_perl/5.8.3 /opt/perl_32/lib/vendor_perl .) at ./prova.pl line 3.
I've got all installed! DBI.pm is installed!
If you have root, type in console (Debian/Ubuntu):
sudo apt-get install libdbi-perl
If you don't have active perl (and hence don't have ppm), you can also get DBI like this:
perl -MCPAN -e 'install DBI'
You may need to install drivers for Postgres like this:
perl -MCPAN -e 'install DBD::Pg'
For redhat/centos users:
sudo yum -y install perl-DBI
DBI isn't in your #INC path, which tells perl where to look for custom modules. This is probably because you've installed them using the cpan tool as a non-root user, which won't have write access to the default include paths.
You will need to locate DBI.pm and other packages, and move them into your #INC path.
Alternatively, find the packages you've installed and add the install path into your library path, for one time use:
PERL5LIB=/path/to/modules perl yourscript.pl
And for a more permanent solution, add this to ~/.bashrc:
export PERL5LIB=/path/to/modules
For alpine users use perl-dbi: apk add perl-dbi
For arch linux users:
sudo pacman -S perl-dbi

installing mongodb with pecl

this is what i get:
bitnami#ip-10-117-57-211:/bin$ sudo pecl install mongo
downloading mongo-1.4.0.tgz ...
Starting to download mongo-1.4.0.tgz (138,495 bytes)
..............................done: 138,495 bytes
84 source files, building
WARNING: php_bin /opt/bitnami/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Can't load '/opt/bitnami/perl/lib/5.8.8/i686-linux/auto/Data/Dumper/Dumper.so' for module Data::Dumper: /opt/bitnami/perl/lib/5.8.8/i686-linux/auto/Data/Dumper/Dumper.so: undefined symbol: PL_sv_undef at /opt/bitnami/perl/lib/5.8.8/i686-linux/XSLoader.pm line 70.
at /opt/bitnami/perl/lib/5.8.8/i686-linux/Data/Dumper.pm line 36
Compilation failed in require at /usr/share/autoconf/Autom4te/C4che.pm line 33.
BEGIN failed--compilation aborted at /usr/share/autoconf/Autom4te/C4che.pm line 33.
Compilation failed in require at /usr/bin/autom4te line 38.
BEGIN failed--compilation aborted at /usr/bin/autom4te line 38.
ERROR: `phpize' failed
Any ideas how to fix?
Try configuring manually as it seems bitnami is a bit funky:
$ sudo apt-get update
$ sudo apt-get install build-essential libtool autoconf unzip wget
Download the latest source code from the web page, uncompress it and compile the module.
$ wget http://pecl.php.net/get/mongo-1.4.3.tgz
$ tar -zxf mongo*
$ export PHP_AUTOCONF=/usr/bin/autoconf
$ export PHP_PREFIX=/opt/bitnami/php
$ cd mongo-*
$ /opt/bitnami/php/bin/phpize
$ ./configure
$ make
$ sudo make install
Adapted from: http://wiki.bitnami.com/Components/PHP#How_to_install_OAuth_module.3f
well i finally got it working. I ran through the steps to install mongo extension on mac server and it worked for my bitnami lamp stack.
The instructions were on this blog:
http://andres.jaimes.net/857/setup-php-mongo-on-mac/

Need help installing Spreadsheet::ParseExcel

I am trying to install Spreadsheet::ParseExcel to use with ExcelLatex. This is what I did:
Installed Active perl, Then install CPAN.pm by perl -MCPAN -e shell
I was asked for configuration and mirror site and I let perl do the auoconfoguration. At the end I got the following message: Autoconfiguration complete.Then I tried:
perl -MCPAN -e 'install "Spreadsheet::WriteExcel"'
And it tried to install it but at the end I got the following error:
ERROR: Can't create '/Library/Perl/5.12/Spreadsheet'
mkdir /Library/Perl/5.12/Spreadsheet: Permission denied at /System/Library/Perl/5.12/ExtUtils/Install.pm line 494
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
JMCNAMARA/Spreadsheet-WriteExcel-2.37.tar.gz
/usr/bin/make install -- NOT OK
I really appreciate it one please help me how I can solve the problem
It is trying to create a directory in the root (mkdir /Library/Perl/5.12/Spreadsheet)
You have to be root to be able to do that.
You may could use PerlBrew or local::lib to install your perl libs into your home dir.
# Install Spreadsheet::WriteExcel and its missing dependencies to the '~/perl5' directory
perl -MCPAN -Mlocal::lib -e 'CPAN::install(Spreadsheet::WriteExcel)'
# Just print out useful shell commands
$ perl -Mlocal::lib
export PERL_MB_OPT='--install_base /home/username/perl5'
export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5'
export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5'
export PATH="/home/username/perl5/bin:$PATH"
#create a environment setting script and execute it.
perl -Mlocal::lib > ~/.setenv && . ~/.setenv
Regards,

Error When Trying to Install DBD::Oracle with CPANM

Okay, so I was trying to install a combination of the CGI module, DBI module, and DBD::Oracle driver using CPANM on a 64bit Solaris 11 machine with an Oracle11g database.
I installed that latest version of Perl using Perlbrew, updated CPANM, and then did the following...
cpanm -v -f -i CGI
cpanm -v -f -i DBI
And both of those modules installed fine, the DBI did have a small test error (t/zvxnp_85gofer.t) when I tried to install it normally, but the force install seemed to work.
So then I went to try to install the final part that I needed:
cpanm -v -f -i DBD::Oracle
And this was the error that came out towards the end of the installation...
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
LD_RUN_PATH="/opt/oracle/rdbms/lib" gcc -G -L/usr/gnu/lib -fstack-protector Oracle.o dbdimp.o oci8.o -o blib/arch/auto/DBD/Oracle/Oracle.so \
-L/opt/oracle/rdbms/lib/ -lclntsh -lkstat -lnsl -lsocket -lresolv -lgen -ldl -lsched -lrt -R/opt/oracle/rdbms/lib -laio -lposix4 -lkstat -lm -lpthread \
ld: fatal: file /opt/oracle/rdbms/lib//libclntsh.so: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to blib/arch/auto/DBD/Oracle/Oracle.so
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/DBD/Oracle/Oracle.so'
FAIL
! Installing DBD::Oracle failed. See /home/oracle/.cpanm/build.log for details.
I'm guessing just from the wrong ELF class: ELFCLASS64 it has to do with some mismatch between the 64 bit binaries that exist and that this driver requires the 32 bit binaries to install? Some research has indicated that I need to find the lib32 directory to continue the installation, but I can't seem to find it.
I did:
echo $ORACLE_HOME ---> /opt/oracle/rdbms
ls $ORACLE_HOME
That returned the following directories...
apex emcli mgw rdbms
assistants has network relnotes
bin hs nls root.sh
ccr ide oc4j scheduler
cdata install odbc slax
cfgtoollogs install.platform olap sqldeveloper
clone instantclient ons sqlj
config inventory OPatch sqlplus
crs j2ee opmn srvm
csmig javavm oracore sysman
css jdbc oraInst.loc timingframework
ctx jdev ord ucp
cv jdk oui uix
dbs jlib owb utl
dc_ocm ldap owm wwg
deinstall lib64 perl xdk
demo log plsql
diagnostics md precomp
dv mesg racg
So I see a lib64, but no lib or lib32. Has anyone ever had this problem before, found a solution to it, or know how I could continue from here?
I had the same issue. Fixed it by doing ./Configure -es -Dprefix=$HOME/usr/local -Dcc=gcc -Duse64bitall -Dusethreads for perl install
please take a look at 1271236.1 and 883702.1 at oracle.com. It will explain how to get the 32bit libraries for 11i client installation.