Use Imagemagic C library with anjuta

530 views Asked by At

I tried to compile ImageMagic c codes in http://www.imagemagick.org/script/magick-wand.php in anjuta. I downloaded and compiled ImageMagic successfully then add the library to anjuta from project->Add Library...

Then I tried to run the code below got from above link

#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main(int argc,char **argv)
{
#define ThrowWandException(wand) \
{ \
  char \
    *description; \
 \
  ExceptionType \
    severity; \
 \
  description=MagickGetException(wand,&severity); \
  (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
  description=(char *) MagickRelinquishMemory(description); \
  exit(-1); \
}

MagickBooleanType
  status;

MagickWand
  *magick_wand;

if (argc != 3)
  {
    (void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
    exit(0);
  }
/*
  Read an image.
*/
MagickWandGenesis();
magick_wand=NewMagickWand();  
status=MagickReadImage(magick_wand,argv[1]);
if (status == MagickFalse)
  ThrowWandException(magick_wand);
/*
  Turn the images into a thumbnail sequence.
*/
MagickResetIterator(magick_wand);
while (MagickNextImage(magick_wand) != MagickFalse)
  MagickResizeImage(magick_wand,106,80,LanczosFilter,1.0);
/*
  Write the image then destroy it.
*/
status=MagickWriteImages(magick_wand,argv[2],MagickTrue);
if (status == MagickFalse)
  ThrowWandException(magick_wand);
magick_wand=DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);
}

But I got this errors.

main.o: In function ‘main’:
main.c'.35: undefined reference to ‘MagickWandGenesis'
main.c'.36: undefined reference to ‘NewMagicWand'
main.c:37: undefined reference to ‘ MagickReadImage'
main.c39: undefined reference to ‘ MagickGefException'
main.c:39: undefined reference to ‘MagickRelinquishMernory'
main.c:43: undefined reference to ‘ MagickResetlterator'
main.c:45: undefined reference to ‘ Magickkesimelmage
main.c:l4: undefined reference to ‘ MagickNextImage'
main.c:49: undefined reference to ‘Magickwritelmages'
main.c:51: undefined reference to ‘ MagickGetException'
main.c:51: undefined reference to ‘Magickkelinquishuemory
main.c:52: undefined reference to ‘ DestroyMagickWand'
main.c:53: undefined reference to ‘MagickWandTerminus'
collect2: Id returned 1 exit status

Please help me to fix this

1

There are 1 answers

0
Nayana Priyankara On BEST ANSWER

I think I found the solution, After I install libmagickwand-dev program works correctly using, sudo apt-get install libmagickwand-dev command After I added MagicWand to libraries from project->Add library to anjuta –