Discussion:
Problems with the "new" constructor in a GD-derived module
(too old to reply)
Shlomi Fish
2006-07-24 11:02:28 UTC
Permalink
Hi all!

This is my first message to this list. To cut to the chase, I'm trying to
write a derived class from the "GD" distribution in CPAN (
http://search.cpan.org/dist/GD/ ). The code I have now is here:

http://eskimo.shlomifish.org/Files/files/code/perl/gd-phpfilter/

(Note that I wrote it for work, so it may be considered an in-house code of
sorts, and not really open-source yet. But it's perfectly OK to look at it.)

Now my problem is that I'm getting the following on "./Build test":

<<<
t/01-object.......ok 1/10Can't locate auto/GD/new.al in @INC (@INC
contains: /home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/lib
/home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/arch
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8
I inherit from "GD" and also have my own new() function (which I think is
unnecessary), so I don't know what I'm doing wrong.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish ***@iglu.org.il
Homepage: http://www.shlomifish.org/

Chuck Norris wrote a complete Perl 6 implementation in a day but then
destroyed all evidence with his bare hands, so no one will know his secrets.
Sisyphus
2006-07-24 12:07:11 UTC
Permalink
----- Original Message -----
From: "Shlomi Fish" <***@iglu.org.il>
To: <perl-***@perl.org>
Sent: Monday, July 24, 2006 9:02 PM
Subject: Problems with the "new" constructor in a GD-derived module
Post by Shlomi Fish
Hi all!
This is my first message to this list. To cut to the chase, I'm trying to
write a derived class from the "GD" distribution in CPAN (
http://eskimo.shlomifish.org/Files/files/code/perl/gd-phpfilter/
(Note that I wrote it for work, so it may be considered an in-house code of
sorts, and not really open-source yet. But it's perfectly OK to look at it.)
<<<
contains: /home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/lib
/home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/arch
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8
I inherit from "GD" and also have my own new() function (which I think is
unnecessary), so I don't know what I'm doing wrong.
I don't use Module::Build (though I have it), so I wrote a Makefile.PL,
relocated lib/PHPFilter.xs and typemap to the top level, and tried to build
the ol' fashioned way. First problem was that I needed to remove your "TODO
..." comments from the XS file. I thought the same would be necessary if you
were using Module::Build. And then I couldn't see any reference to the GD
header or library in Build.pl, though I expected that would need to be
specified, too. Did 'PHPFilter.so' actually get built for you ? It didn't
for me, though I think I gave it every chance of succeeding. Sticking point
for me was that `gdImageGrayScale' could not be resolved - so the build
process failed at the 'make' stage. Where is that symbol defined ? it's not
in my version (2.0.33) of GD.

When I tried to build using your source "straight out of the box" with
Module::Build, the shared object did not get built for the very same reason.
It strikes me as a bug in Module::Build that the 'test' phase could then be
run .... but, like I said, I don't use Module::Build ... and I know little
about it (or its quirks and limitations :-)

Cheers,
Rob
Shlomi Fish
2006-07-24 12:55:02 UTC
Permalink
Hi!

Thanks for your help. See below for my comments.

I forgot to note that I'm using Mandriva Cooker (about to become Mandriva
2007) with perl-5.8.8-6mdk and gcc-4.1.1-2mdk on a P4-2.4GHz machine.
Post by Sisyphus
----- Original Message -----
Sent: Monday, July 24, 2006 9:02 PM
Subject: Problems with the "new" constructor in a GD-derived module
Post by Shlomi Fish
Hi all!
This is my first message to this list. To cut to the chase, I'm trying to
write a derived class from the "GD" distribution in CPAN (
http://eskimo.shlomifish.org/Files/files/code/perl/gd-phpfilter/
(Note that I wrote it for work, so it may be considered an in-house code
of
Post by Shlomi Fish
sorts, and not really open-source yet. But it's perfectly OK to look at
it.)
Post by Shlomi Fish
<<<
contains: /home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/lib
/home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/arch
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8
I inherit from "GD" and also have my own new() function (which I think is
unnecessary), so I don't know what I'm doing wrong.
I don't use Module::Build (though I have it), so I wrote a Makefile.PL,
relocated lib/PHPFilter.xs and typemap to the top level, and tried to build
the ol' fashioned way. First problem was that I needed to remove your "TODO
..." comments from the XS file. I thought the same would be necessary if
you were using Module::Build.
Indeed, I believe I fixed them in the copy on the web.
Post by Sisyphus
And then I couldn't see any reference to the
GD header or library in Build.pl, though I expected that would need to be
specified, too.
That's the case indeed. I started from what Module::Starter::XSimple gave me,
(which so far only supports building module templates using M::B) and since I
was able to build everything so far, that's what I used. But I do need to add
it somehow.
Post by Sisyphus
Did 'PHPFilter.so' actually get built for you ?
It was:

<<<<
shlomi:~/progs/perl/cpan/GD-PHPFilter-0.01$
ls -l ./blib/arch/auto/GD/PHPFilter/PHPFilter.so
-rwxr-xr-x 1 shlomi shlomi 8962 Jul 24
15:49 ./blib/arch/auto/GD/PHPFilter/PHPFilter.so
Like I said - I'm still a newbie at this, and it's the first time I'm trying
to use Module::Build (which I only happily used for pure Perl modules so far)
for PerlXS stuff.
Post by Sisyphus
It didn't
for me, though I think I gave it every chance of succeeding. Sticking point
for me was that `gdImageGrayScale' could not be resolved - so the build
process failed at the 'make' stage. Where is that symbol defined ? it's not
in my version (2.0.33) of GD.
Hmmm... Maybe it's a function that the PHP guys coded in C. I'll have to
check.
Post by Sisyphus
When I tried to build using your source "straight out of the box" with
Module::Build, the shared object did not get built for the very same
reason. It strikes me as a bug in Module::Build that the 'test' phase could
then be run .... but, like I said, I don't use Module::Build ... and I know
little about it (or its quirks and limitations :-)
OK.

<<<
shlomi:~/Docs/homepage/homepage/trunk$ perl -MModule::Build -le 'print
$Module::Build::VERSION'
0.2801
But maybe I should switch to ExtUtils::MakeMaker.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish ***@iglu.org.il
Homepage: http://www.shlomifish.org/

Chuck Norris wrote a complete Perl 6 implementation in a day but then
destroyed all evidence with his bare hands, so no one will know his secrets.
Nick Ing-Simmons
2006-07-24 17:31:19 UTC
Permalink
Post by Shlomi Fish
Hi all!
This is my first message to this list. To cut to the chase, I'm trying to
write a derived class from the "GD" distribution in CPAN (
http://eskimo.shlomifish.org/Files/files/code/perl/gd-phpfilter/
I haven't unpacked that yet.
Post by Shlomi Fish
(Note that I wrote it for work, so it may be considered an in-house code of
sorts, and not really open-source yet. But it's perfectly OK to look at it.)
<<<
contains: /home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/lib
/home/shlomi/progs/perl/cpan/GD-PHPFilter-0.01/blib/arch
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8/i386-linux
/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.8.8
Message suggests that AutoLoader is trying to create a sub new for you in GD.
Post by Shlomi Fish
I inherit from "GD" and also have my own new() function (which I think is
unnecessary), so I don't know what I'm doing wrong.
So does _your_ new call GD's new?
Do your code cause GD.pm to be loaded?
XS code would normally create its 'new' in XS code not by AutoLoader.

Also with GD one usually does

my $imgage = GD::Image->new(...)

rather than

my $imgage = GD->new(...)

So should you be inheriting from GD::Image rather than GD ?
Post by Shlomi Fish
Regards,
Shlomi Fish
---------------------------------------------------------------------
Homepage: http://www.shlomifish.org/
Chuck Norris wrote a complete Perl 6 implementation in a day but then
destroyed all evidence with his bare hands, so no one will know his secrets.
Loading...