J'ai compilé avec succès un programme C par GCC sur Mac avec la bibliothèque GD2 installée directement depuis les sources. Maintenant, je suis en train de le faire avec GD2 installé via MacPorts et ont le message d'erreur suivant:Problème pour compiler un programme C par GCC avec la bibliothèque GD2 installée via MacPorts
plotgeometry.c:5:16: error: gd.h: No such file or directory
plotgeometry.c: In function 'PlotGeometry':
plotgeometry.c:28: error: 'gdImagePtr' undeclared (first use in this function)
plotgeometry.c:28: error: (Each undeclared identifier is reported only once
plotgeometry.c:28: error: for each function it appears in.)
plotgeometry.c:28: error: expected ';' before 'im'
plotgeometry.c:29: warning: ISO C90 forbids mixed declarations and code
plotgeometry.c:748: error: 'im' undeclared (first use in this function)
plotgeometry.c:748: warning: implicit declaration of function 'gdImageCreate'
plotgeometry.c:752: warning: implicit declaration of function 'gdImageColorAllocate'
plotgeometry.c:780: warning: implicit declaration of function 'gdImageSetPixel'
plotgeometry.c:801: warning: implicit declaration of function 'gdImagePng'
plotgeometry.c:809: warning: implicit declaration of function 'gdImageDestroy'
Je suppose que je dois fournir le chemin de la bibliothèque GD2 pour GCC. Le gd.h
se trouve dans les dirs suivantes
$ find /opt/local/ -name 'gd.h'
/opt/local//include/gd.h
/opt/local//var/macports/software/gd2/2.0.35_7/opt/local/include/gd.h
J'ai ajouté /opt/local/include
à ma variable $PATH
, mais il did't aide. Ai-je besoin de rediriger un paramètre supplémentaire avec ce chemin vers GCC? Pourriez-vous m'aider?
Merci, Marcelo! Si j'ajoute 'CFLAGS + = '-I/opt/local/include'' à' Makefile', alors je compile 'plotgeometry.c'. Cependant, il y a un problème lors de la collecte: 'ld: bibliothèque introuvable pour -lgd' – Andrei
Y a-t-il une série de fichiers' libgd * 'dans'/opt/local/lib'? Avez-vous également ajouté le préfixe 'LDFLAGS'? (Basé sur le message d'erreur, vous n'avez probablement pas besoin de 'LDLIBS'.) –
Ok, désolé, cela fonctionne après avoir lu toutes vos réponses! – Andrei