Compile and linker problems: help
Posted: 2009-12-18T01:33:19-07:00
Hi,
I have written this C code that work well as stand-alone software. I'm trying to integrate it on a preexisting software, but without success.
The code is the following
I have understood that the problem is on the call magick_wand = NewMagickWand() ...If I make the code more simple as the following
It will work only if I comment the line magick_wand = NewMagickWand() . Probably there is a problem on MagickWand function call. Can you help me?
Thank
NB when i compile the stand-alone code i use the following command cc `MagickWand-config --cflags --cppflags` -o wand wand.c `MagickWand-config --ldflags --libs` that can be simplified as cc -Wall -lMagickWand wand.c -0 wand. when i compile the preexisting software there is a Makefile that define the compilation and linkage parameters.
I have written this C code that work well as stand-alone software. I'm trying to integrate it on a preexisting software, but without success.
The code is the following
Code: Select all
void DrawText(char *inputImage, char *outputImage, char *outputFormat, char *conferenceName, char *data, char *userName, char *userID) {
MagickBooleanType status;
MagickWand *magick_wand = NULL;
DrawingWand *d_wand = NULL;
PixelWand *p_wand = NULL;
[b] magick_wand = NewMagickWand();[/b]
d_wand = NewDrawingWand();
p_wand = NewPixelWand();
// fixed data
char *user = "Utente";
char *ID = "ID";
// initialize MagickWand environment
MagickWandGenesis();
// Read the image.
status = MagickReadImage(magick_wand, inputImage);
if (status == MagickFalse) {
printf("Unable to Read\n");
//ThrowWandException(magick_wand);
}
// Scale the image dimension
if (strcmp(outputFormat,"CIF") == 0)
status = MagickScaleImage(magick_wand, 352, 288);
else if (strcmp(outputFormat,"QCIF") == 0)
status = MagickScaleImage(magick_wand, 176, 144);
else
printf("Invalid output format %s\n", outputFormat);
if (status == MagickFalse) {
printf("Unable to Scale\n");
//ThrowWandException(magick_wand);
}
// Set up the font size and colour
DrawSetFont(d_wand,"Helvetica");
PixelSetColor(p_wand,"black");
DrawSetFillColor(d_wand,p_wand);
DrawSetFontSize(d_wand,28);
// Now draw the text
DrawAnnotation(d_wand,10,50,(const unsigned char *) conferenceName);
DrawSetFontSize(d_wand,14);
DrawAnnotation(d_wand,150,15,(const unsigned char *) data);
// different font, colour and size
PixelSetColor(p_wand,"green");
DrawSetFillColor(d_wand,p_wand);
DrawSetFontSize(d_wand,20);
DrawSetFont(d_wand,"Times-Roman");
// Now draw the text
DrawAnnotation(d_wand,30,90,(const unsigned char *) user);
// same size and colour
DrawSetFont(d_wand,"Times-Roman");
DrawAnnotation(d_wand,180,90,(const unsigned char *) ID);
// Draw the image on to the magick_wand
MagickDrawImage(magick_wand, d_wand);
// and write it
status = MagickWriteImage(magick_wand, outputImage);
/* Clean up */
if (status == MagickFalse)
//ThrowWandException(magick_wand);
if(magick_wand) magick_wand = DestroyMagickWand(magick_wand);
if(d_wand) d_wand = DestroyDrawingWand(d_wand);
if(p_wand) p_wand = DestroyPixelWand(p_wand);
// terminate the MagickWand environment
MagickWandTerminus();
printf("\n%s,%s,%s,%s,%s,%s\n",inputImage, outputImage, conferenceName, data, userName, userID);
}
Code: Select all
void DrawText(char *inputImage, char *outputImage, char *outputFormat, char *conferenceName, char *data, char *userName, char *userID) {
MagickBooleanType status;
MagickWand *magick_wand = NULL;
DrawingWand *d_wand = NULL;
PixelWand *p_wand = NULL;
[b] magick_wand = NewMagickWand();[/b]
It will work only if I comment the line magick_wand = NewMagickWand() . Probably there is a problem on MagickWand function call. Can you help me?
Thank
NB when i compile the stand-alone code i use the following command cc `MagickWand-config --cflags --cppflags` -o wand wand.c `MagickWand-config --ldflags --libs` that can be simplified as cc -Wall -lMagickWand wand.c -0 wand. when i compile the preexisting software there is a Makefile that define the compilation and linkage parameters.