41

I'm a C/C++/Java/Unix geek by trade, but now I have to write a Perl program in Windows. So I've got Cygwin, Eclipse with EPIC installed, and simple test programs run. I do not have a Unix machine available to me that I can run Eclipse on.

But I need to use Net::TCP::Server and I can't figure out how to install it. It doesn't appear to be part of the Cygwin Perl install, and I don't want to spend 5 days learning the world of Perl and CPAN and Perl configuration. I just want to write my program.

Any simple ways of installing a Perl module in Cygwin? I'm thinking something like apt-get install would be nice, but I expect that's too much to hope for.

Thanks

famousgarkin
  • 13,687
  • 5
  • 58
  • 74
stu
  • 8,461
  • 18
  • 74
  • 112
  • 1
    http://strawberryperl.com/ - check it out. – Mat May 07 '12 at 14:16
  • From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [What's the easiest way to install a missing Perl module?](http://stackoverflow.com/questions/65865/whats-the-easiest-way-to-install-a-missing-perl-module) – daxim May 07 '12 at 14:34
  • 3
    Net::TCP::Server is abandoned, did not have a release in 10(!) years. I do not recommend it since - judging from the testers' reports and the bug tracker - you will have difficulties installing it and/or making it work. Instead use [IO::Socket::INET](http://p3rl.org/IO::Socket::INET) (core module) when on Perl 5.14 or later, or else [IO::Socket::IP](http://p3rl.org/IO::Socket::IP). – daxim May 07 '12 at 14:41
  • I'll check this out, thanks. I'm just fixing up a program somebody else wrote. – stu May 07 '12 at 14:46

5 Answers5

36
$ perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> install Net::TCP::Server

And it's instructive to list the configuration with the o conf command.

Jens
  • 69,818
  • 15
  • 125
  • 179
  • Running make test PERL_DL_NONLAZY=1 /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00basic.t .. panic: no address for 'Net::TCP::TCP_RPTR2RXT' in 'Gen.c' at /usr/lib/perl5/5.10/i686-cygwin/DynaLoader.pm line 223. BEGIN failed--compilation aborted at /home/smark/.cpan/build/Net-ext-1.011-v2seXU/blib/lib/Net/Gen.pm line 194. Compilation failed in require at t/00basic.t line 268. – stu May 07 '12 at 14:52
  • 1
    So I get the above when I try to install it. It looks like it compiles okay (lots of warnings) and then I get that when making the test program – stu May 07 '12 at 14:53
  • 1
    You might use it even when some tests failed (with a grain of salt). As daxim points out, this may be due to bit rot of that package and you should think about using up-to-date modules with equivalent functionality. – Jens May 07 '12 at 19:20
  • 1
    That's just a roundabout way of doing: `cpan Net::TCP::Server` – ikegami Feb 16 '17 at 18:57
  • It says `Can't locate CPAN.pm in @INC (you may need to install the CPAN module)`. How to fix? – pmor Feb 13 '23 at 08:31
  • Fixed using [this](https://stackoverflow.com/a/60301616/1778275) answer. – pmor Feb 13 '23 at 08:43
6

Seeing that some of the info here is a bit outdated and too complicated, I'd rather suggest the following. There are a few different Perl package managers in use. They are all installed with cpan (which is already part of the Cygwin Perl installation), like this:

# Install ppm (outdated)
cpan PPM 

# Install cpanp (still used)
cpan CPANPLUS

# Install cpanm (most recent)
cpan App::cpanminus

Then you can install any Perl package you like, as for example in the OP, using cpanm:

cpanm Net::TCP::Server

Sometimes (as noted above) Cygwin may fail certain tests. For example, when using IPv6 on a machine only configured with IPv4, or when your windows firewall is blocking some tests, etc. To attempt to install anyway, try to use the force flag; -f.

cpanm -f Net::TCP::Server
not2qubit
  • 14,531
  • 8
  • 95
  • 135
4

I'm a C/C++/java unix geek by trade, but now I have to write a perl program in windows. So I've got cygwin, eclipse with EPIC installed, and simple test programs run. I do not have a unix machine available to me that I can run eclipse on.

You should be able to run Eclipse with EPIC right under Windows without Cygwin. I like Cygwin for many things, but it isn't exactly a very stable platform. Eclipse runs as a Java program, so all you have to do is make sure Java is installed on your PC. There is even a pre-built Eclipse package.

You can also get a decent Perl that runs right under Windows. Either ActivePerl or Strawberry Perl. Either one will work although many Unix heads prefer Strawberry Perl because it comes with the same MIGW environment that Cygwin has and many feel it's more compatible with the Unix Perl brethren. However, ActiveState Perl can use the Perl Package Manager (PPM) that contains pre-built modules. Unfortunately, the module you want isn't available via PPM.

But I need to use Net::TCP::Server and I can't figure out how to install it. It doesn't appear to be part of the cygwin perl install, and I don't want to spend 5 days learning the world of perl and cpan and perl configuration. I just want to write my program.

Installing from CPAN is really quite simple. The first time you run CPAN, it should pretty much configure itself. Then, to do an install, you run cpan install Net::TCP::Server and that should be it. However, I've tried on several Mac, Unix, and Linux machines, and I can't get it to work. So, this isn't a Windows problem as much as a problem with this module. It is fairly old, and might not work well in newer versions of Perl. You might have to force the install over test's objections.

Maybe you can use one of the already installed IO modules that come with Perl instead. That'll save you a boatload of trouble because the required modules are part of Perl's existing package.

David W.
  • 105,218
  • 39
  • 216
  • 337
3

Despite Cygwin's "problems," I use it regularly whenever I have to use Windows. I would recommend first installing a separate installation of Perl using perlbrew so that you won't interfere with Cygwin's copy of Perl in case something bad happens since Cygwin does not enforce root-user policy. In cygwin shell, type

\curl -L http://install.perlbrew.pl | bash

This should walk through the installation for perlbrew and set it up in one of your executable path. Next type

perlbrew init
perlbrew install --force stable
perlbrew switch stable

Wait a bit while a mint Perl is compiled. For unknown reason, Perl can only pass 99.23% of the core module tests on Cygwin (at least on my machine),hence the --force flag). My experience is that it mostly have something to do with handling of device files, like ports and pipes. I am unaware of people trying to resolve the issue as it seems like a Cygwin problem. Although it has not presented much problem for me with general system and web programming tasks. The module testing routines will fail if any problem exists so I am not fretting over it.

Next step is to install cpanm (cpanminus), type

perlbrew install-cpanm

From here on out, to install any library from CPAN, just type

cpanm [library::name1] [library::name2]

cpanm makes it trivial to install any Perl modules. You can even install from your local directory instead of CPAN.

salty-cat-fish
  • 111
  • 1
  • 3
0

Your mileage may vary, but I had a lot of trouble until I realized that Strawberry perl had a lot of bin folders in my PATH, and when I changed my .bashrc to export only a very simple PATH=/bin:/usr/bin:/usr/local/bin, Cygwin's perl installation's cpan started working beautifully. I used local:lib as Cygwin doesn't support sudo. Before it got into a bad loop saying "Press SPACE and ENTER to exit Patch" over and over.

sflitman
  • 111
  • 2
  • 5