in reply to Inline::C and gd

Beatnik,

This works for me (you can place the "include" within the code section). Your problem is quite odd since the c example works while the perl does not. If you do a "perl -V" do you see /usr/lib in the linker and libs section? Was your perl compiled with gcc? If it was another compiler/linker, that linker may not know about /usr/lib.

#!/usr/local/bin/perl use Inline C => DATA => LIBS => '-lgd'; outtext(); __END__ __C__ #include "gd.h" int outtext() { gdImagePtr im; FILE *out; im = gdImageCreate(100,100); out = fopen("foo.jpg", "wb"); gdImageJpeg(im, out,-1); fclose(out); gdImageDestroy(im); return 1; }
-derby

Replies are listed 'Best First'.
Re: Re: Inline::C and gd
by Beatnik (Parson) on May 26, 2002 at 13:28 UTC
    a perl -V dump returns something like this :
    Compiler: cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include', Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl. +a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
    When I run the code you provided, I still get an error :)
    Had problems bootstrapping Inline module 'derby_pl_e0f6' Can't load '/path/derby/_Inline/lib/auto/derby_pl_e0f6/derby_pl_e0f6.s +o' for module derby_pl_e0f6: /home/beatnik/code/cstuff/gd/derby/_Inli +ne/lib/auto/derby_pl_e0f6/derby_pl_e0f6.so: undefined symbol: jpeg_de +stroy at /usr/lib/perl5/5.6.1/i386-linux/DynaLoader.pm line 206. etc
    I'm using Perl 5.6.1 on RH7.2 and Inline 0.43.
    gd.h is at
    /usr/include/gd.h /usr/local/include/gd.h
    and libgd is at
    /usr/lib/libgd.so.1 /usr/lib/libgd.so.1.8 /usr/lib/libgd.so.1.8.4 /usr/lib/libgdk.so.1.0.6 /usr/lib/libgdk.so.1 /usr/lib/libgd.a /usr/lib/libgd.so /usr/local/lib/libgd.a
    If this helps somewhat...

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      Okay. That's a different error message (undefined symbol jpeg_destroy). Doing an "nm -a libgd.so | grep jpeg_destroy" on my system shows that libgd.so has an unresolved dependency for that function. jpeg_destory is part of the jpg library. Do you have libjpg.so anywhere in your libpths?

      -derby

        libjpeg is located at the following locations...
        /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so.62.0.0 /usr/lib/libjpeg.so.6 /usr/lib/libjpeg.so.6.0.1 /usr/lib/libjpeg.a /usr/lib/libjpeg.la /usr/lib/libjpeg.so

        My gcc is gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

        Greetz
        Beatnik
        ... Quidquid perl dictum sit, altum viditur.