Automatically correct Lingua::LinkParser include lib path - perl

I'm building a script that will run on an EC2 instance that will automatically install our required packages and modules.
I'm having an issue with Perl module Lingua::LinkParser.
During compile it complains
LinkParser.xs:5:27: error: link-includes.h: No such file or directory
On Ubuntu link-includes.h is provided by package link-grammar and is installed in /usr/include/link-grammar/.
However Lingua::LinkParser's Makefile.PL is hard-coded(?) to look in /usr/local/include/link-grammar/.
Is there simple-ish way to resolve this issue?

Distroprefs
Best practice for using slightly modifying module from CPAN?
Install Perl modules that require customized options via CPAN

mob's suggestion above to just symlink /usr/include/link-grammar to /usr/local/include/link-grammar is the simplest way of handling this situation and this is what I'll use.

Related

CPAN first launching configuration

I'm taking a look into Perl as a total beginner. I want to try some CPAN modules.
When I run an install command on my Osx console, CPAN asks for a configuration with the following statement :
To install modules, you need to configure a local Perl library
directory or escalate your privileges. CPAN can help you by
bootstrapping the local::lib module or by configuring itself to use
'sudo' (if available). You may also resolve this problem manually if
you need to customize your setup.
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
What is the difference between local::lib and sudo options ?
If I understand it well, it installs some modules locally on my computer. But I don't see any difference between the two config above.
If you use sudo, CPAN will use root to install the libraries in a central location where all users on the machine can access the files without any special configuration. If you use 'local::lib', it will create a library in your home directory and install the modules such that only perl programs that have been configured to look for modules in your home directory will find the modules.
Perl uses the special variable #INC to search for module paths. So you can install modules anywhere as long as you set #INC properly before you use them. This article explains the basics.
http://www.symkat.com/find-a-perl-modules-path
You can do all kinds of fun stuff with #INC; one of my favorite hacks it to put a function pointer in there and use custom perl code to lookup modules.
Good question. When you use local::lib, you can install Modules via CPAN User specific in an given directory. Assume you choose sudo as approach, you install Modules global.
Its like installing Node.js via npm. When you install a module with npm install -g <Modul>, its global installed and you can use it everywhere. But withouth that -g flag, its just available inside your current directory.
Its about the same here, except that you choose the default way of installing CPAN Modules.

How can I auto install missing perl modules when running a script?

I am looking for a way to auto install a missing perl module when my script runs. I would like to use cpan plus since it "seems" to available on both Windows and Linux but maybe I could have a way to drop down to standard cpan if cpan plus is not installed.
So how could one go about this? There is of course the cpan plus / cpan modules but are those able to integrated into a script?
Check this module: Carton Carton in CPAN, so first you installed all modules for your script, then you will make special dependency file under Carton and as result using this special file in other PC to install all dependency for you script. Please read description of this module in CPAN.
I hope it will help you.

I'm confused about installing WWW::Curl for Perl in Cygwin

I have already installed Perl and libcurl using Cygwin's package manager. Now, I'm trying to install WWW::Curl. I have to specify the cURL include directory in WWW::Curl's Makefile.PL, but I have no idea where to look for this. Thanks for your time.
It will try to guess automatically. If it does not work, see the README.
P.S. LWP is more convenient to use.
edit: Using your package managers own packages is often preferred when using your system perl, cygwin has a package for perl-WWW-Curl, install this package rather than building your own.
Most likely I think you are missing the libcurl-devel package. Although you mention that libcurl is installed, please ensure that libcurl-devel is installed via the cygwin package management application, and try again if required.
WWW:Curl will search for the correct include path, looking for curl/curl.h, if it cannot find the file then it might be looking in the wrong places, you'll have to do a manual install:
download and unpack the package from cpan
read the included README file to understand this process
search your cygwin installation for a file called curl/curl.h note the directory that it is in.
modify the Makefile.PL so that #includes has the directory noted above included.
run perl Makefile.PL
run make && make install
This process is essentially the same problem as the process for a native Win32/strawberry perl install, in that it doesnt know where libcurl is located. you can check the README.Win32 file for similar instructions.
The libcurl-devel package installs the curl/curl.h file to usr/include/ which is a path that is already searched by Makefile.PL.
To however you say you have no idea where to look, locate the curl.h you can do the following:
find / -name curl.h
But be warned this could take a long time, you could try specific locations such as /usr
find /usr -name curl.h
Or even better you can look at the package contents to find the file location:
https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86%2Flibcurl-devel%2Flibcurl-devel-7.41.0-1&grep=libcurl
To echo Alexandr's answer, LWP is more convenient to use cross platform, while covering the same features, it can also do a lot more.

Which Perl modules can be installed just by copying lib files?

I'm an absolute beginner at Perl, and am trying to use some non-core modules on my shared Linux web host. I have no command line access, only FTP.
Host admins will consider installing modules on request, but the ones I want to use are updated frequently (DateTime::TimeZone for example), and I'd prefer to have control over exactly which version I'm using.
By experimentation, I've found some modules can be installed by copying files from the module's lib directory to a directory on the host, and using
use lib "local_path";
in my script, i.e. no compiling is required to install (DateTime and DateTime::TimeZone again).
How can I tell whether this is the case for a particular module? I realise I'll have to resolve dependencies myself.
Additionally: if I wanted to be able to install any module, including those which require compiling, what would I be looking for in terms of hosting?
I'm guessing at the moment I share a VM with several others and the minimum provision I'd need would be a dedicated VM with shell access?
See perldoc perlxs.
You can probably inspect the module's source for DynaLoader or something like this. This way you can find out if a module uses any C code.
If you use a unix-like OS, you can use a package manager to see what files/libraries a package (perl module) installs.
You can use
use lib "your_local_path" ,
In this case , you can have module in your local path.

What is a quick way to run a single script to automatically install missing modules using only Perl core?

I inherited a project which is supposed to be able to be deployed to other servers. This project has a number of simple module dependencies which however might not be present on all target machines.
As such I'd like to be able to run a single command line script that checks which Perl modules are installed and tries to automatically install missing ones via CPAN.
Since this should be very basic (i.e. needing to install stuff to run the module installer would defeat the point) said script should only use Perl 5.8.8 core modules.
Does something like that exist already or would i need to write it myself?
Creating a Bundle package is one possible answer.
You can then look at something like CPAN::Shell (see CPAN module) to automate the process.
/I3az/
Update re: brian's comment about Task:: - Here are some pertinent links:
Writing a CPAN Task (using Module::Install)
"Task:: or Bundle::"? (Perlmonks)
Use Module::Install, it will be bundled with your module/program. You can use "auto_install" command to automatically install dependencies.