Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Please advice how to install the Person module "use Person;" on my linux machine The perl script use - obj oriented

why I get the following:

 [root@linux /tmp/Pogo-0.10]# perl Makefile.PL
 Note (probably harmless): No library found for -lg++
 Note (probably harmless): No library found for -lgcc
 Note (probably harmless): No library found for -lclient
 Writing Makefile for Pogo


[root@linux /tmp/Pogo-0.10]# make


g++ -c  -I/usr/local/goods/inc -fno-strict-aliasing -pipe -Wdeclaration-after-statement -    
I/usr/local/include -D_LARGEFILE_SOURCE -Dc
/bin/sh: g++: command not found
make: *** [Pogo.o] Error 127

my perl script:

#!/usr/bin/perl


use strict;
use warnings;
use Person;

 my $p = Person->new();

 $p->varName('Anna');

 $p->varAge(30);

 print $p->varName." is ".$p->varAge." years old.\n";
share|improve this question
add comment

1 Answer 1

Object Oriented Perl

If your focus is on learning Object-Oriented Perl, not on learning Pogo, I suggest you just follow one of perl's built-in tutorials by running the command: perldoc perltoot. This would quickly lead you to the following solution:

file Person.pm

package Person;
use strict;

sub new {
  my $self = {};
  $self->{NAME} = undef;
  $self->{AGE}  = undef;
  bless $self;
  return $self;
}

sub varName {
  my $self = shift;
  if (@_) { $self->{NAME} = shift; }
  return $self->{NAME}
}

sub varAge {
  my $self = shift;
  if (@_) { $self->{AGE} = shift; }
  return $self->{AGE}
}

1;

file person.pl

#!/usr/bin/perl
use strict;
use warnings;
use Person;

my $p = Person->new();
$p->varName('Anna');
$p->varAge(30);
print $p->varName." is ".$p->varAge." years old.\n";

Running it:

 $ perl person.pl
 Anna is 30 years old.

Perl Modules

You asked

how to install the Person module

You seem to be installing a module named Pogo not one named "Person".

why I get the following: ... /bin/sh: g++: command not found

It seems you don't have a full development kit installed. Have you checked the documentation for your Linux distribution? Each different distribution has their own package manager you can use to install a development kit.

You can try to use the cpan command but I expect you might have the same problem.


RHEL Development Tools

In order to install perl modules that are not "pure perl" you will need a C or C++ compiler and some other tools and libraries. What follows is extracted from a Slicehost article that I believe applies to RHEL 5.4 generically (I use CentOS, so I have no direct experience of installing RHEL packages)

Package repositories

RHEL comes with a basic set of repositories.

Have a look at the enabled repositories by running:

sudo yum repolist enabled

Each repository listed should include a brief description and the number of packages available from that source.

If you'd like to have a look at the configuration files that point to each repository, they're stored in this directory:

/etc/yum.repos.d

If you look through one of the files there, you will see each repository has a set of definitions including which mirror to use and what gpg key to use (and actually whether to check the package signature at all).

You can, of course, add more repositories whenever you want to but I would just give a word of caution: Some of the available repositories are not officially supported and may not receive any security updates should a flaw be discovered.

Update

Now we can update the package list that yum uses.

The following command will also offer to install any updated packages. As with all installs have a careful look at the list and, once happy, press 'y' to continue:

sudo yum update

Once any updates have been installed, we can move on to installing some essential packages.

Development Tools

RHEL has some handy meta-packages that include sets of pre-defined programs required for a single purpose.

So instead of installing a dozen different package names, you can install just one meta- package. One such package is called 'Development Tools'. Issue the command:

sudo yum groupinstall 'Development Tools'

Notice the programs that are to be installed include gcc, make, patch and so on. All these are needed for many other programs to install properly. A neat system indeed.

Enter 'y' and install them.

Now we have the necessary packages should we want to build an application from source.

Done


CentOS

If you have not paid for a RHEL subscription and registered it, I suspect you might not have access to RedHat package repositories. You would therefore be unable to install packages such as the development tools. There are ways to work around this but the sensible course of action is to install CentOS instead - it is almost exactly like RedHat (omitting RedHat trademarks and copyrighted images etc) but has working repositories that can be used without paying a subscription fee.

share|improve this answer
    
@RedGrittyBrick hi where I can find the "full development kit" ? –  yael Feb 9 '11 at 10:58
    
@yael, what Linux distribution and version are you using? Ubuntu 10.10 Desktop? If so sudo aptitude update && sudo aptitude install g++ –  RedGrittyBrick Feb 9 '11 at 11:27
    
my linux - Red Hat OS release.5.4 –  yael Feb 9 '11 at 11:33
    
@Yael: For RHEL 5.4 yum groupinstall "Development Tools" You may also need yum groupinstall "Development Libraries". –  RedGrittyBrick Feb 9 '11 at 11:37
    
but I get - yum groupinstall "Development Tools" Loaded plugins: security Setting up Group Process Warning: Group Development Tools does not exist. No packages in any requested group available to install or update –  yael Feb 9 '11 at 11:54
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.