How to install XML::Parser without expat-devel? - perl

XML::Parser fails to build on a quite fresh 64-bit Debian box. After issuing cpan XML::Parser, cpan fails with lots of errors about Expat.c and Expat.xs:
[...]
Expat.xs:2182: error: ‘CallbackVector’ has no member named ‘skip_until’
Expat.c: In function ‘XS_XML__Parser__Expat_Do_External_Parse’:
Expat.c:2904: error: ‘XML_Parser’ undeclared (first use in this function)
Expat.c:2904: error: expected ‘;’ before ‘parser’
Expat.xs:2194: error: ‘parser’ undeclared (first use in this function)
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/root/.cpan/build/XML-Parser-2.41-rpV6ok/Expat'
make: *** [subdirs] Error 2
TODDR/XML-Parser-2.41.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Message at the start of the output explains that expat-devel is needed for building.
Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' package with your
OS package manager. See 'README'.
But expat-devel is not in Debian repository.
Is it possible to get over this without need to build/install expat from source?

The package you want to install is named libexpat1-dev. You could also just install libxml-parser-perl via apt-get. Or if you really want to install via CPAN try installing the Debian packages dependencies first via apt-get build-dep libxml-parser-perl.

libexpat1-dev contains both libexpat and expat.h, which are both mentioned in the message as well:
If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:
EXPATLIBPATH=... To set the directory in which to find libexpat
EXPATINCPATH=... To set the directory in which to find expat.h
Installing libexpat1-dev seems to solve the problem:
$ aptitude install libexpat1-dev

There is always the manual method - to build/install expat from source.
(This example shows installing to an alternative location for XAMPP | LAMPP)
Download from:
http://sourceforge.net/projects/expat/files/expat/
tar zxf /[where-ever]/expat-2.1.0.tar.gz -C /tmp
cd /tmp/expat-2.1.0
/opt/lampp/bin/perl ./configure --prefix=/opt/lampp LDFLAGS=-L/opt/lampp/lib
make
make install
http://search.cpan.org - search for and download - XML::Parser
tar zxf /[where-ever]/XML-Parser-2.41.tar.gz -C /tmp
cd /tmp/XML-Parser-2.41
/opt/lampp/bin/perl ./Makefile.PL EXPATLIBPATH=/opt/lampp/lib EXPATINCPATH=/opt/lampp/include
make
make test
make install

Work like a charm in Ubuntu 15.04. The only thing that I need is install Perl XML Parser with:
sudo apt-get install libxml-parser-perl
And following the instructions here, I was able to import successfully all my ratings into Rhythmbox. Now, the only work that I need to do is create again the smart play lists, that is nothing compared with my entire libray ratings.

Today I had the same issue wanting to complile the new GIMP 2.9.4 beta on OSX 10.8 and the aid of homebrew.
First install perl
brew install perl
Then the XML::Parser module by going into the perl shell with
perl -MCPAN -e shell
And inside the shell install XML::Parser by typing
install XML::Parser
Exit shell
exit
Now, verify it has been installed successfully. If everything is ok, you will not see an error.
perl -e "require XML::Parser"
If the ./configure still fails missing XML::Parser, then intltools is not using the perl you have installed. Looking at the script tells me it does the test with $INTLTOOL_PERL -e "require XML::Parser". Trying a echo $INTLTOOL_PERL gave out nothing, so the magic is to set it with
export $INTLTOOL_PERL=perl
Now run ./configure again.

None of the above methods worked for me. I had the right environment variables setup but they were somehow not picked up by cpanm that I use to install perl modules. Expat was also installed.
Here is what I did to overcome the same problem that OP is reporting.
This is very close to what #LadyBuzz suggested.
Download the XML::Parser from cpan.org
Extract the tarball into directory and descend to it.
Open the Makefile.pl and edit the first lines to actually have the absolute paths to both: EXPATLIBPATH and EXPATINCPATH
Save the Makefile.pl, go up one level and create a new tarball with the Makefile.pl that you just edited.
Execute cpanm on the newly created tarball.
This resulted in successful installation of the module.

Related

Mac M1 Homebrew Perl Carton Net::SSLeay is loading libcrypto in an unsafe way

I'm trying to install Net::SSLeay with Carton.
The installation fails with this message
Configuring Net-SSLeay-1.90 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
WARNING: /opt/homebrew/Cellar/perl/5.32.1_1/bin/perl is loading libcrypto in an unsafe way -> N/A
I've tried this with system perl, brew perl and multiple perlbrew perls.
Google came up with a temp solution to build homebrew using x86_64 architecture.
This did work for the libcrypto error, but gave me a whole different set of issues including mysql not running anymore.
Other "solutions" that I've tried are symlinking libssl & libcrypto as suggested by numerous other posts, all sadly without success.
Any ideas how to fix this or work around this without having to reinstall all brew packages as x86_64 ?
Quick Workaround
If you are looking for a quick workaround follow these steps.
Run carton bundle to create a vendor cache directory.
Go to cached tarball 'cache/authors/id/C/CH/CHRISN/' and unpack tar -xvzf Net-SSLeay-1.90.tar.gz
Edit Makefile.PL, change my $prefix = find_openssl_prefix(); to
my $prefix = '/opt/homebrew/opt/openssl#1.1'; ** adjust to your openssl location.
Save and create new tarball tar -czvf Net-SSLeay-1.90.tar.gz Net-SSLeay-1.90
Run carton install --cached to use the altered version
Hope this helps anyone in search of workaround
You can solve this in two steps:
upgrade ExtUtils::MakeMaker to at least version 7.58 (e.g. cpanm ExtUtils::MakeMaker)
install openssl via macports (sudo port install openssl) or homebrew (brew install --cask openssl)
After the Monterey update this broke again also on the x86_64 architecture, but just symlinking your latest openssl (where ever it is, depending how you have installed it) seemed to fix this. Example:
$ export OPENSSL_PREFIX=[find your openssl installation]
$ sudo ln -s $OPENSSL_PREFIX/lib/libssl.dylib /usr/local/lib/
$ sudo ln -s $OPENSSL_PREFIX/lib/libcrypto.dylib /usr/local/lib/
Better workaround:
I entered export OPENSSL_PREFIX=/opt/homebrew/opt/openssl#1.1 in my shell and then ran cpan. I checked the code in Makefile.PL and the first thing the function find_openssl_prefix does is to check the OPENSSL_PREFIX environment variable. If it is set, then it the function will return its contents.
Add the variable to your .profile, .cshrc, .bashrc, .zshrc, or whatever rc file your shell uses and you never have to worry about it again!!

HTML::TokeParser not able to install from CPAN

I am not able to install HTML::TokeParser this package from CPAN.
cpan[6]> install HTML::TokeParser
Running install for module 'HTML::TokeParser'
Running make for G/GA/GAAS/HTML-Parser-3.71.tar.gz
Has already been unwrapped into directory /root/.cpan/build/HTML-Parser-3.71-0zUSqw
Could not make: Unknown error
Running make test
Can't test with enter code here out successful make
Running make install
Make had returned bad status, install seems impossible
Can anyone help here?
you can try:
perl -MCPAN -e 'install HTML::TokeParser'
OR
Download the zipped tar file from one of the following:
http://search.cpan.org/~gaas/HTML-Parser-3.71/lib/HTML/TokeParser.pm
or
search.cpan.org/CPAN/authors/id/G/GA/GAAS/HTML-Parser-3.71.tar.gz
Unzip the module as follows or use winzip:
tar -zxvf HTML-Parser-3.71.tar.gz
The module can be installed using the standard Perl procedure:
perl Makefile.PL
make
make test
make install # You may need to be root
make clean # or make realclean

Cannot install Date::Calc perl module

I'm running Solaris on my machine and I would need to install the Date::Calc perl module in order for one of my scripts to work.
When I run the following command:
sudo perl -MCPAN -e 'install Date::Calc'
I get the following error:
Tests succeeded but one dependency not OK (Bit::Vector)
STBEY/Date-Calc-6.3.tar.gz
[dependencies] -- NA
Running make install
make test had returned bad status, won't install without force
I have no prior experience in Perl development, so I have no clue about what the error might be or where to get more information.
What should I do to fix this?
When trying to install Bit::Vector first, i.e. when running the following command:
sudo perl -MCPAN -e 'install Bit::Vector'
i get the following error message:
Checking if your kit is complete...
Looks good
Writing Makefile for Bit::Vector
Writing patchlevel.h for /usr/bin/perl (5.012003)
cp lib/Bit/Vector/Overload.pm blib/lib/Bit/Vector/Overload.pm
cp Vector.pm blib/lib/Bit/Vector.pm
cp Vector.pod blib/lib/Bit/Vector.pod
cp lib/Bit/Vector/Overload.pod blib/lib/Bit/Vector/Overload.pod
cp lib/Bit/Vector/String.pod blib/lib/Bit/Vector/String.pod
cp lib/Bit/Vector/String.pm blib/lib/Bit/Vector/String.pm
cc -c -DPTR_IS_LONG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -xO4 -DVERSION=\"7.2\" -DXS_VERSION=\"7.2\" -KPIC "-I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE" BitVector.c
sh: line 1: cc: not found
*** Error code 127
make: Fatal error: Command failed for target `BitVector.o'
STBEY/Bit-Vector-7.2.tar.gz
/usr/bin/make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
I installed gcc via the following commands (as adviced here):
pkg install gcc-45
pkg install system/header
but I still get the same error when trying to install Bit::Vector. Indeed, when I type cc on the command-line, I get the command not found error. When I type gcc, however, I get gcc: no input files.
The error means that Bit::Vector (a dependency of Date::Calc) failed to install for some reason. Bit::Vector requires compiling C code, which means your CPAN configuration will need access to the C compiler and libraries (and headers) that were used to build your perl.
From what I understand, that can sometimes be painful on Solaris.
If you have another C compiler available, you might consider building and installing a local Perl using perlbrew.
So it turns out that the only option is to install the Oracle Solaris Studio prior to installation of new perl modules which need to compile C code.
From a related discussion at Oracle Solaris forum:
CC modification in /usr/perl5/5.12/lib/i86pc-solaris-64int/Config.pm
will not resolve the compilation issue. New errors will be produced
and some part will not use this variable.
By default, this method to build modules will use perl compiled
options. And in this case, as we used Oracle Studio, this software
will be required because some options are not available with gcc.
I tried with Oracle Studio, and the compilation was done successfully.
If you want to use gcc, then this will be very tricky to modify
several perl config files. An another method is to compile manually
each necessary modules after you customize each Makefile.

Getting WebKit bindings to work with Perl and gkt2

I need to use WebKit in my perl + gtk2 application. Found a package Gtk2::WebKit on CPAN, but can't get it working.
cpan> install Gtk2::WebKit
gives following output:
Package webkit-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `webkit-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'webkit-1.0' found
at inc/Module/Install/PRIVATE/WebKit.pm line 24
*** can not find package webkit-1.0
*** check that it is properly installed and available in PKG_CONFIG_PATH
at inc/Module/Install/PRIVATE/WebKit.pm line 24
No 'Makefile' created'YAML' not installed, will not store persistent state
FLORA/Gtk2-WebKit-0.09.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Failed during this command:
FLORA/Gtk2-WebKit-0.09.tar.gz : writemakefile NO -- No 'Makefile' created
It looks as if cpan wasn't able to find webkit, but I'm not sure how to fix that (my first time using perl and cpan).
Env: perl 5.12.4, ubuntu 11.10
Install libwebkitgtk-devel: sudo apt-get install libwebkitgtk-devel.
sudo apt-get install libwebkitgtk-dev
For Debian/Ubuntu and similar, the package name to install is libwebkitgtk-dev.
For OpenSuse and other RPM-based systems, the package name is libwebkitgtk-devel.

Why can't I install DBD::mysql so I can use it with Maatkit?

I'm trying to install Maatkit following the maatkit instructions. I can't get past having to install DBD::mysql. "Warning: prerequisite DBD::mysql 1 not found."
When I try to install DBD::mysql from cpan, I get very helpful "make had returned bad status, install seems impossible".
Perl is "v5.8.8 built for darwin-thread-multi-2level", the one that came with OS X. I also tried building from source with same result.
We need more of the error message. Most likely, you are missing the MySQL client development files. I don't know how to install these on OSX. Also see this older post on OSX 10.5.2 , in which some other failures with the mysql client libraries are found.
Possibly post this question with more parts of your error message at perlmonks.org, if stackoverflow doesn't allow for convenient pasting of your make session or rather the last 20 or 10 lines of it.
Some more Googling with site:perlmonks.org also finds this post which has some more details on things to watch out for when installing DBD::MySQL. Depending on how comfortable you feel with the installation, you might want to manually run the tests, supplying a test database and test user or even skip testing the module.
After a bit more googling, this worked for me:
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
sudo ln -s /usr/local/mysql/include /usr/local/mysql/include/mysql
sudo perl -MCPAN -e 'install Bundle::DBD::mysql'
press enter a bunch of times, then in your maatkit folder:
perl Makefile.PL
sudo make install
and you'll find the mk-* programs in /usr/local/bin/
You will want to install MySQL first. I usually use the binary packages they provide for OS X. The packages do include the headers and MySQL client libraries which DBD::MySQL requires. Once the MySQL package is installed, DBD::MySQL should install without issue.
Here is my output:
$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite DBD::mysql 1 not found.
Writing Makefile for maatkit
$ mysql --version
mysql Ver 14.12 Distrib 5.0.51b, for apple-darwin9.0.0b5 (i686) using readline 5.0
I notice that there are in effect DBD::MySQL packages in the fink repositories. For example:
ayaz#ayazs-macbook$ fink list | grep -i 'dbd-mysql'
dbd-mysql-pm586 3.0008-10 Perl5 Database Interface to MySQL
dbd-mysql-pm588 3.0008-10 Perl5 Database Interface to MySQL
Perhaps installing through fink one of those packages may help alleviate your troubles.
Also, and I cannot be certain of this, you may want to install for MySQL-5.x (if you have that version installed) the mysql15-dev and mysql15-shlibs packages. I installed those through fink thus:
$ sudo fink --use-binary-dist install mysql15-dev