Léa-Linux & amis :   LinuxFR   GCU-Squad   GNU
Problème avec la librairie GD
Envoyé par: Brigadier

Bonjour,

pour tester l'installation de GD chez nous, un prof nous a fourni un code de test.
J'ai installé toutes les bibliothèques mais j'obtiens cette erreur :
g++ -lgd -lpng -lz -ljpeg -lfreetype -lm gd.cc
/tmp/ccqjEmrL.o: dans la fonction « main »:
gd.ccsad smiley.text+0xc5): référence indéfinie vers « gdImageJpeg »
collect2: ld a retourné 1 code d'état d'exécution
Je ne comprends pas pourquoi gdImageJpeg n'est pas reconnue

Voici le code :
/* Bring in gd library functions */
extern "C" {
#include <gd.h>
       }


/* Bring in standard I/O so we can output the PNG to a file */
#include <stdio.h>

int main() {
    /* Declare the image */
    gdImagePtr im;
    /* Declare output files */
    FILE *pngout, *jpegout;
    /* Declare color indexes */
    int black;
    int white;

    /* Allocate the image: 64 pixels across by 64 pixels tall */
    im = gdImageCreate(64, 64);

    /* Allocate the color black (red, green and blue all minimum).
        Since this is the first color in a new image, it will
        be the background color. */
    black = gdImageColorAllocate(im, 0, 0, 0);   

    /* Allocate the color white (red, green and blue all maximum). */
    white = gdImageColorAllocate(im, 255, 255, 255);   
   
    /* Draw a line from the upper left to the lower right,
        using white color index. */
    gdImageLine(im, 0, 0, 63, 63, white);   

    /* Open a file for writing. "wb" means "write binary", important
        under MSDOS, harmless under Unix. */
    pngout = fopen("test.png", "wb");

    /* Do the same for a JPEG-format file. */
    jpegout = fopen("test.jpg", "wb");

    /* Output the image to the disk file in PNG format. */
    gdImagePng(im, pngout);

    /* Output the same image in JPEG format, using the default
        JPEG quality setting. */
    gdImageJpeg(im, jpegout, -1);

    /* Close the files. */
    fclose(pngout);
    fclose(jpegout);

    /* Destroy the image in memory. */
    gdImageDestroy(im);
}

Poste le Sunday 11 March 2007 10:04:16
Répondre     Citer    
Re: Problème avec la librairie GD
Envoyé par: duff

Salut,

Regardes si la librairie GD a été compilée avec la libjpeg, essayes ça:

ldd /chemin/vers/libgd.so
Tu auras les librairies utilisées par la GD, et notemment les librairies d'image (PNG, Jpeg, ...)

Duff

Poste le Monday 12 March 2007 16:50:14
Répondre     Citer    

Veuillez vous authentifier auparavant pour commenter.

 

Ce forum !
Problème avec la librairie GD
Pour poser vos questions sur les scripts shell, le Perl, le C, etc... Attention : nous ne sommes pas des spécialistes du dev, ce forum est juste pour de petites aides ponctuelles concernant le développement et les outils de développement.

Sauf mention contraire, les documentations publiées sont sous licence Creative-Commons