How to link library to compile/install a Perl module manually? - perl

I want to compile/install a Perl module that depends on a library that is not in Strawberry Perl 5.12. I used Strawberry on a Windows box to install the module (Net-SSH2). The installation failed because it requires the library (libssh2). My issue is similar to this guy's http://www.perlmonks.org/bare/?node_id=814455. But I cannot use that solution because it does not apply to my Perl version and more important, I have very restricted Internet connection.
I downloaded the libssh2 library, but I don't know how specify the include path in the Makefile.PL so I can run:
perl Makefile.PL
make
make install
I appreciate any help or pointer.

Edit your Makefile.PL and add or edit the INC and/or LIBS parameters in the WriteMakefile call. See the ExtUtils::MakeMaker docs for the expected format. These will be passed to the compiler and linker.

Net::SSH2 is included in latest beta of Strawberry Perl. Another option is to unpack this archive into Strawberry's directory.

Related

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.

Trying to install YAML::Syck - This module requires a C compiler

I'm trying to install the YAML::Syck module (I'm actually trying to install Date::Manip, this is just a dependency), but it fails with the following message:
This module requires a C compiler at Makefile.PL line 38.
This happens whether I try to install using CPAN or if I try to download the packages and install manually.
I have gcc installed and on my PATH, I can access it from the same CYGWIN shell window that I'm trying to use to install YAML::Syck.
When looking for a C compiler, ExtUtils::MakeMaker and Module::Build don't necessarily look for gcc in your PATH, but query your perl's configuration for the C compiler it has been built with and expects it to be available for building Perl extensions as well.
On my system, it will look for cc in PATH, as per
$ perl -MConfig -E'say $Config{cc}'
cc
I've had trouble in the past getting everything to "just work" with cygwin, when it comes to compiling modules. You might want to take a look at Strawberry Perl, which is a Windows Perl distribution that comes bundled with all of the components needed for compilation of XS modules. I haven't personally tried to install YAML::Syck with it, but I have installed many other XS modules without incident.
Once it is installed and in your path (usually automatically), you should be able to run cpan from the Windows command prompt to install the module.
Maintainer speaking
The better forum to ask is the cygwin mailinglist. There you will find the same questions being asked again and again, we can point to the messages, and the
maintainers are present.
The quality of the answers will be much better.
The official latest perl announcement was http://sourceware.org/ml/cygwin-announce/2012-07/msg00011.html
perl used to bundle most useful modules for CPAN and Testing with the core perl.
With the latest 5.14 package the useful modules were moved to the seperate package perl_vendor.
The dependencies to be able to compile modules by your own via cpan are not included.
You'll need make and gcc-4 at least.
See /usr/share/doc/Cygwin/perl.README for the package specific README.
YAML::Syck is considered broken and unmaintained (*_why* left), please try to use a better YAML package, like YAML or YAML::XS, written by the inventor and author of YAML itself (ingy).
Date::Manip does not require YAML::Syck. cpan does like to have a YAML modules, but prefers YAML::XS.
You'll find out that you'll be able to install much more packages with cygwin perl than with strawberry perl (=mingw).

How do I install a Perl module that's on Sourceforge and not CPAN using ActiveState?

Trying to install Ptkdb on Windows 7 with Perl 5.12.2 (ActiveState) — how do I do this?
ptkdb is available on CPAN. It's also available for Perl 5.12 in the bribes repository:
ppm install http://www.bribes.org/perl/ppm/Devel-ptkdb.ppd
For pure Perl modules, all you need to do is run the Makefile.PL that comes with the module. If the module is a mix of Perl and C, you will need to get a C/C++ compiler for Windows that works with your distribution of Perl. I would recommend asking around for a Windows binary first if it's a mixed module.

Windows equivalent of perl modules required (not available in activestate ppm) such as file::finder

I'm attempting to import code written in linux into eclipse's perl plugin 'epic', and have installed activestate perl in windows. Most of the modules have an activestate equivalent, but some of them I can't find in ppm. Does anyone know how I can get the following modules so that the code can compile?
File::Finder
Spreadsheet::WriteExcel::Utility
Sybase::CTlib
Sybase::DBlib
Sybase::Xfer
Template
Template::Constants
DBD::Sybase
File::Rsync
PerlIO/gzip
The best option is probably to remove Active Perl and replace it with Strawberry Perl. Because the Strawberry Perl installation includes a compiler, you are able to install most CPAN modules using the standard CPAN shell.
Trouchelle to the rescue!
http://trouchelle.com/perl/ppmrepview.pl?l=Template-Toolkit&v=10
The other modules cannot be built because of test failures or missing libraries.
i downloaded the File:finder module from cpan and was able to install successfully in the windows.
Only difference is we need to use nmake instead of make.
You can download perl modules from https://metacpan.org/ and then compile the same in windows.

How do I install a module and its dependencies in ActivePerl on Windows?

I want to send emails using gmail's smtp servers and perl. I am trying to install Email::Send::Gmail, but it is not clear to me what are the steps to install it. It seems that it depends on other modules that I do not have installed.
This is partially dependent on which distribution of Perl you're using.
ActivePerl includes a utility called PPM (Perl Package Manager) for installing modules. It handles dependency resolution automatically. PPM is particularly nice for installing XS modules on Windows where a compiler isn't typically available. The downside to PPM is that it some CPAN modules aren't available (probably because they fail ActiveState's automated build process). You can run PPM from either the start menu or by typing ppm at a command prompt.
A more general option is to use the interactive CPAN shell. Note that you must have a compiler to install XS modules using this method. You can access the cpan shell by typing cpan at a command prompt.
The brute-force approach of last resort is to download tarballs from CPAN and manually install them one at a time. When an install aborts due to unsatisfied dependencies download and install them then go back to the first module and try again.
Type:
cpan Email::Send::Gmail
… at the command prompt.
It's probably a good idea to set up local::lib first.
Or see the Perl Foundation Wiki on installing CPAN modules or the same but without root access.
Or see the CPAN guide to installing modules.
If you are using ActivePerl, try the PPM (Perl Package Manager) tool that comes with ActivePerl first. When you tell it to install a module, it should handle all of the dependencies for you.
Note the dependency tree for Email::Send::Gmail. Some of those modules require additional installation of third party software, most notably OpenSSL, which cpan won't do for you.
You can probably install it with:
perl -MCPAN -e shell
install Email-Send-Gmail
Hope it helps,
/Klaus
If you can, CPAN. (ha! It rhymes ... what a crime. Oops, did it again! When will this end... :p) It's essentially the way to install modules for your system. It automatically detects dependencies, downloads, installs, and tests them all for you, and backs out if ever a build or test fails. It's a fantastic and reliable way of installing modules. This works great if you're using essentially any Perl distribution besides ActiveState's distribution, including Strawberry Perl. Generally, this is done with
cpan Module::Name
or, in an interactive mode,
$ cpan
cpan > install Module::Name
If you're using ActiveState Perl, then you probably want to use ActiveState's PPM (Perl Package Manager). It's similar to CPAN, except everything comes prebuilt for ActiveState Perl. ActiveState has a document on how to use their Perl Package Manager on their website, including a graphical example.
If the easy options fail, you are not out of luck. There's some more complex, but manual methods you can do to still install the module.
Most modules that you can download will have within them a bit of metadata in a .yaml file; this will help you figure out whether or not you have all your dependencies. CPAN and PPM automatically resolve and install all your dependencies, but doing it manually will not, leaving that task up to you.
Assuming you have all your dependencies, and you need to install it manually, look for one of two files: Makefile.PL or Build.PL. If you have a Makefile.PL, cd to the directory you extraced the module within a command prompt, and type:
perl Makefile.PL
make
make test
make install
You will need a 'make' program on your system. If it's ActiveState Perl, you may need to install the module manually (see a paragraph or two down.)
If it happens to have a Build.PL, then you need to do a slightly different set of steps:
perl Build.PL
Build
Build test
Build install
(Of course, you may want to consider not installing if make/Build test fails, but that's up to you.)
As a final alternative, if your module has no xs files (ie, code that needs to be compiled on install), and all dependencies are met, you can simply move the files in the lib folder to your perl installation's site\lib folder. If you're interested in just using it for one project, you can add a PERL5LIB environmental variable, pointing to a new, custom library directory (eg, /my/project/lib) and then before running your tool, make sure the environment is set up.
As a followup, see PerlFaq8 - How do I install a module from CPAN.
Also, see PerlFaq8 - How do I keep my own module/library directory?.
Mixing installation methods is asking for heartache and headaches you don't need.
Don't use CPAN with Active Perl. Use PPM.*
PPM download sources can be found at Randy Kobes' site.
If you can't find a PPM of a module you need, you can build your own PPMs easily with Mr. Kobes make_ppm.
You can download a distribution and simply run make_ppm to build a PPM, but I prefer to do the a more "normal" build process:
perl Makefile.PL
make
make test
make_ppm
*If you install your files outside of c:/perl/site/* then it's OK to use CPAN. Just don't co-mingle CPAN shell modules with PPM modules.