Can't locate loadable object for module GD in @INC


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can't locate loadable object for module GD in @INC
# 1  
Old 02-13-2009
Data Can't locate loadable object for module GD in @INC

I am trying to use the GD module on a on Unix Solaris environment machine by including gd.pm from a temporary location
but I am receiving the following error:

perl -w polyline.pl > imageoutput.png
Can't locate loadable object for module GD in @INC (@INC contains: /home2/work/tmp/Work1/GD-2.01 /opt/perl/5.8.0.1/lib/5.8.0/sun4-solaris /opt/perl/5.8.0.1/lib/5.8.0 /opt/perl/5.8.0.1/lib/site_perl/5.8.0/sun4-solaris /opt/perl/5.8.0.1/lib/site_perl/5.8.0 /opt/perl/5.8.0.1/lib/site_perl .) at /home2/work/tmp/Work1/GD-2.01/GD/Polyline.pm line 49
Compilation failed in require at /home2/work/tmp/Work1/GD-2.01/GD/Polyline.pm line 49.
BEGIN failed--compilation aborted at /home2/work/tmp/Work1/GD-2.01/GD/Polyline.pm line 49.
Compilation failed in require at polyline.pl line 13.
BEGIN failed--compilation aborted at polyline.pl line 13.

The following is my code.


use lib "/home2/work/tmp/Work1/GD-2.01";
##use GD;
use GD::Polyline;

$PI = 3.14159; $TWO_PI = 2 * $PI;
sub r2d {$_[0] * 180 / $PI};

$splinekey = "<UL><LI>Green: original polygon or polyline<LI>Blue: control points added with addControlPoints()<LI>Black: spline generated by toSpline()</UL>";

if (1) {

##use GD;
##use GD::Polyline;

# create an image
$image = new GD::Image (500,300);
$white = $image->colorAllocate(255,255,255);
$black = $image->colorAllocate( 0, 0, 0);
$red = $image->colorAllocate(255, 0, 0);

# create a new polyline
$polyline = new GD::Polyline;

# add some points
$polyline->addPt( 0, 0);
$polyline->addPt( 0,100);
$polyline->addPt( 50,125);
$polyline->addPt(100, 0);

# polylines can use polygon methods (and vice versa)
$polyline->offset(200,100);

# rotate 60 degrees, about the centroid
$polyline->rotate(3.14159/3, $polyline->centroid());

# scale about the centroid
$polyline->scale(1.5, 2, $polyline->centroid());

# draw the polyline
$image->polydraw($polyline,$black);

# create a spline, which is also a polyine
$spline = $polyline->addControlPoints->toSpline;
$image->polydraw($spline,$red);

# output the png
#binmode STDOUT;
#print $image->png;

SampleImage($image, "polyline-synopsis.png", "Synopsis", "Polyline created by 'SYNOPSIS' section of documentation.");

}

if (1) {
$image = NewImage();

$offset = 50;


for $poly (new GD::Polygon, new GD::Polyline) {

$table_info = [];

$poly->addPt( 0, 0);
$poly->addPt( 0,100);
$poly->addPt( 50,125);
$poly->addPt(100, 0);

#print "this " . ref($poly) . " has " . $poly->length() . " points\n";

push @$table_info, ["<B>".ref($poly)."</B>"];
push @$table_info, ['vertex number: ', 0..($poly->length()-1)];

@coords = $poly->vertices();
@coords = map {"[".int($_->[0]).",".int($_->[1])."]"} @coords;
push @$table_info, ['coordinates (pre-offset): ', @coords];

@lengths = $poly->segLength();
@lengths = map {int($_+0.5)} @lengths;
#print "segLengths are : @lengths\n";
#print "perimeter is : " . int($poly->segLength()) . "\n";
push @$table_info, ['segment lengths: ', @lengths];

@angles = $poly->segAngle();
@angles = map {int(r2d($_)+0.5)} @angles;
#print "seg angles are : @angles\n";
push @$table_info, ['segment angles: ', @angles];

@angles = $poly->vertexAngle();
@angles = map {defined ($_) ? int(r2d($_)+0.5) : "undef"} @angles;
#print "vertex angles are: @angles\n";
push @$table_info, ['vertex angles: ', @angles];

$poly->offset(50 + $offset,80);
$offset += 200;

# draw the original poly
$image->polydraw($poly,$black);

#print "\n\n";

push @$summary_table, genHTMLTable($table_info, 0);
}

SampleImage($image, "polyline-simple.png", "Simple", "GD::Polygon and GD::Polyline with same vertexes.</P>" . genHTMLTable([$summary_table], 1));

}

if (1) {
$image = NewImage();

$offset = 50;

for $poly (new GD::Polygon, new GD::Polyline) {

$poly->addPt( 0, 0);
$poly->addPt( 0,100);
$poly->addPt( 50,125);
$poly->addPt(100, 0);

$poly->offset(50 + $offset,80);
$offset += 200;

# draw the original poly
$image->polydraw($poly,$green);

# create and draw the control line for the spline
$ctrlline = $poly->addControlPoints();
$image->polydraw($ctrlline,$cyan);

# create and draw the spline itself
$spline = $ctrlline->toSpline();
$image->polydraw($spline,$black);

}

SampleImage($image, "polyline-spline.png", "Spline", "Splines fit to vertices of polygon and polyline. $splinekey");

}


if (1) {
$image = NewImage();

$triangle = new GD::Polygon;

$triangle->addPt( 0, 0);
$triangle->addPt(-19, 95);
$triangle->addPt( 19, 95);

$triangle->offset(250,50);

foreach (1..9) {
$image->polydraw($triangle,gdBrushed);
$triangle->rotate($TWO_PI / 9, 250, 150);
}

SampleImage($image, "polyline-star9.png", "Nine Pointed Star", "A triangle, rotated about a point other than the origin.<BR>Demonstration of \$poly->rotate() and \$poly->offset()");

}

if (1) {
$image = NewImage();

$cloverControl = new GD::Polyline;
$cloverControl->addPt(45,45);
$cloverControl->addPt(10,10);
$cloverControl->addPt(90,10);
$cloverControl->addPt(55,45);
$cloverControl->addPt(90,10);
$cloverControl->addPt(90,90);
$cloverControl->addPt(55,55);
$cloverControl->addPt(90,90);
$cloverControl->addPt(10,90);
$cloverControl->addPt(45,55);
$cloverControl->addPt(10,90);
$cloverControl->addPt(10,10);
$cloverControl->addPt(45,45);

$clover = $cloverControl->toSpline();

# note that the three following transformations
# could have been called on $cloverControl, instead,
# followed by the above call

$clover->offset($clover->centroid(-1));
$clover->scale(3, 3);
$clover->offset(250, 150);

$image->filledPolygon($clover,$green);

SampleImage($image, "polyline-clover.png", "Clover", "Sample image generated by GD::Polygon");

}

if (1) {
$image = NewImage();

$polyline = new GD::Polyline;

for (0..15) {
$polyline->addPt(30 * $_ + 10, rand(90) + 5);
}

$image->polyline($polyline,$green);

$ctrlline = $polyline->addControlPoints();
$ctrlline->offset(0,100);
$image->polyline($ctrlline,$cyan);

$spline = $ctrlline->toSpline();
$spline->offset(0,100);
$image->polyline($spline,$black);

SampleImage($image, "polyline-zigzag.png", "Zigzag", "Spline fit to random function. $splinekey");

}

if (1) {
$image = NewImage();

$ring_network = new GD::Polygon;

$num_nodes = 10;
$randfactor = 80;

for (1..$num_nodes) {
$x = 250 + 150 * cos($TWO_PI * $_/$num_nodes);
$y = 150 + 100 * sin($TWO_PI * $_/$num_nodes);
$x += rand($randfactor)-$randfactor/2;
$y += rand($randfactor)-$randfactor/2;
$ring_network->addPt($x, $y);
}

$image->setBrush($brush2);
$image->polyline($ring_network->addControlPoints->toSpline,gdBrushed);

$ring_node = new GD::Polygon;

$ring_node->addPt( 0, 0);
$ring_node->addPt(10, 0);
$ring_node->addPt(10,10);
$ring_node->addPt( 0,10);

for $ring_vertex ($ring_network->vertices()) {
$ring_node->offset($ring_node->centroid(-1));
$ring_node->offset(@$ring_vertex);
$image->filledPolygon($ring_node,$grey);
}

SampleImage($image, "polyline-ring-network.png", "Ring Network", "Closed spline fit to nodes at somewhat random positions.");

}

WriteToFile("polyline-example.html", theHTML());

print "\n";
print "open 'polyline-example.html' in your favorite browser that supports PNG.\n";
print "\n";

print "done! " . localtime() . "\n";

##########################
#
# helper functions
#

sub NewImage {
$image = new GD::Image (500,300);

$white = $image->colorAllocate(255,255,255);
$black = $image->colorAllocate( 0, 0, 0);
$grey = $image->colorAllocate(128,128,128);
$red = $image->colorAllocate(255, 0, 0);
$orange = $image->colorAllocate(255,196, 0);
$green = $image->colorAllocate( 0,255, 0);
$blue = $image->colorAllocate( 0, 0,255);
$cyan = $image->colorAllocate( 0,255,255);
$purple = $image->colorAllocate(206, 0,165);

$brush_width = 2;
$brush_color = [255,128,0];
$brush = new GD::Image($brush_width,$brush_width);
$brush->transparent($brush->colorAllocate(255,255,255));
$brush->filledRectangle(0,0,$brush_width,$brush_width,$brush->colorAllocate(@$brush_color));
$brush1 = $brush;

$brush_width = 3;
$brush_color = [206,0,165];
$brush = new GD::Image($brush_width,$brush_width);
$brush->transparent($brush->colorAllocate(255,255,255));
$brush->filledRectangle(0,0,$brush_width,$brush_width,$brush->colorAllocate(@$brush_color));
$brush2 = $brush;

$image->setBrush($brush1);

$image;
}

my $html;

sub SampleImage {
my $image = shift;
my $file = shift;
my $title = shift;
my $text = shift;

WriteToBinaryFile($file, $image->png());

$html .= "<IMG SRC='$file'><BR>\n";
$html .= "<B>$title</B> - $file<BR>\n";
$html .= "<P>$text</P><HR>\n";

}

sub theHTML {
$html;
}

sub WriteToFile {
my $file = shift || return 0;
my $contents = shift || "";

open (NEWFILE, ">" . $file) or die "couldn't write to file $file";
print NEWFILE $contents;
close(NEWFILE);

print "created file $file\n";
}

sub WriteToBinaryFile {
my $file = shift || return 0;
my $contents = shift || "";

open (NEWFILE, ">" . $file) or die "couldn't write to file $file";
binmode NEWFILE;
print NEWFILE $contents;
close(NEWFILE);

print "created file $file\n";
}

sub genHTMLTable {
my $array_of_arrays = shift;
my $border = shift;
my $html_table;

$html_table .= "<TABLE BORDER='$border'>";
for my $array_of_items (@$array_of_arrays) {
$html_table .= "<TR><TD>";
$html_table .= join("</TD><TD>", @$array_of_items);
$html_table .= "</TD></TR>";
}
$html_table .= "</TABLE>";
$html_table;
}



Please help me in knowing what my error is.
Thanks,
Pooja

Last edited by wadhwa.pooja; 02-13-2009 at 03:29 AM..
# 2  
Old 02-13-2009
You probably have to install GD, you can't just use it from another location like you can with a pure perl module.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't locate loadable object for module IO::Tty

I am getting this error: Can't locate loadable object for module IO::Tty in @INC (@INC contains: /production/79p/perl5/lib/site_perl/5.28.0/x86_64-linux /production/79p/perl5/lib/site_perl/5.28.0 /production/79p/perl5/lib/5.28.0/x86_64-linux /production/79p/perl5/lib/5.28.0... (2 Replies)
Discussion started by: mrn6430
2 Replies

2. Shell Programming and Scripting

Inputs required in decoding file on AIX- executable (RISC System/6000) or object module not stripped

Hi, We are in the process of migrating from AIX to Linux. There is a script of type "executable (RISC System/6000) or object module not stripped" on AIX and we are unable to read the contents of it. Is there a way to read the contents of the file on AIX, so that we can rewrite the code in... (3 Replies)
Discussion started by: venkatesh17
3 Replies

3. Shell Programming and Scripting

Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help import rrdtool try: ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2)); except rrdtool.error, e: print e When i run the above i get the below error except... (1 Reply)
Discussion started by: kaf3773
1 Replies

4. Red Hat

modprobe: Can't locate module usbcore

Hello Linux forum! I am working on an older Red hat Linux version(kernel) 2.4.21 and I have compiled the kernel and I select it on startup, but I get the following errors: Mounting Local Filesystems: Modprobe: modprobe: Can't locate module usbcore modprobe: modprobe: Can't locate module udf... (1 Reply)
Discussion started by: mr.rhtuner
1 Replies

5. Shell Programming and Scripting

Can't locate inc/Module/Install.pm in @INC

Hi, I'm trying to install "Date-FromToday" module on my solaris box as below. #perl Makefile.pl (i got the below error) Can't locate inc/Module/Install.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int... (3 Replies)
Discussion started by: admin@2010
3 Replies

6. UNIX for Dummies Questions & Answers

Object reference not set to an instance of an object

I am new to PHP and UNIX. I am using Apache to do my testing on a Windows Vista machine. I am getting this error when I am trying to connect to a web service. I did a search and did not see any posts that pertain to this. Here is my function: <?php function TRECSend($a, $b, $c, $d,... (0 Replies)
Discussion started by: EddiRae
0 Replies

7. Shell Programming and Scripting

Can't locate object method "fetchrow_array" Error

Hi, I have a perl script which is interacting with Database. I have following line of code : ================================================= sub BEGIN { #use Getopt::Std; #getopt ('S'); #($STEAP)=($opt_S); use lib ("/home/perl_lib"); use... (1 Reply)
Discussion started by: rawat_me01
1 Replies

8. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

9. Solaris

Apache on Solaris10 configured with loadable module support?

I have Apache 2 webserver as delivered with the Solaris 10 installation. How to verify if Apache is configured with loadable module support? Or if needs to be recompiled with loadable module support. (2 Replies)
Discussion started by: kavera
2 Replies

10. UNIX for Dummies Questions & Answers

Howto locate locally installed Perl module for a CGI script in APACHE .htaccess

Hi, I have the following simple CGI script, just containg header: #!/usr/bin/perl -w use CGI ':standard'; use lib "/home/myname/lib/perl5/site_perl/5.8.5/"; use Mail::Sendmail; I also have included this directive in ~/public_html/.htaccess : SetEnv PERL5LIB... (0 Replies)
Discussion started by: monkfan
0 Replies
Login or Register to Ask a Question