Compile and linker problems

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "wand/magick_wand.h"

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;

    magick_wand = NewMagickWand();
    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);
}

I have understood that the problem is on the call magick_wand = NewMagickWand() ...If I make the code more simple as the following
1
2
3
4
5
6
7
8
9
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;
   magick_wand = NewMagickWand();


It will work only if I comment the line magick_wand = NewMagickWand() . Probably there is a problem on MagickWand function call. It requires external libraries that are passed to linker with -lMagickWand option.

If i try to add or remove the linker option -lMagickWand i don't see any difference during the compilation.

Can you help me?You are my last chance

Thanks in advance

NB when i compile the stand-alone code i use the following command gcc -Wall -lMagickWand wand.c -0 wand. when i compile the preexisting software there is a Makefile that define the compilation and linkage parameters.


PS

In the Makefile there are a lot of lines...I carry these concerning the compilation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.EXPORT_ALL_VARIABLES:

#
# app_conference defines which can be passed on the command-line
#

INSTALL_PREFIX :=
INSTALL_MODULES_DIR := $(INSTALL_PREFIX)/usr/lib/asterisk/modules

ASTERISK_INCLUDE_DIR ?= ../asterisk/include

REVISION = $(shell svnversion -n .)

# turn app_conference debugging on or off ( 0 == OFF, 1 == ON )
APP_CONFERENCE_DEBUG ?= 0

# 0 = OFF 1 = astdsp 2 = speex
SILDET := 2

# turn app_conference Dummy User on or off ( 0 == OFF, 1 == ON )
APP_CONFERENCE_DU ?= 1

#
# app_conference objects to build
#

OBJS = app_conference.o conference.o member.o frame.o cli.o
TARGET = app_conference.so


#
# standard compile settings
#

PROC = $(shell uname -m)
INSTALL = install

INCLUDE = -I$(ASTERISK_INCLUDE_DIR)
DEBUG := -g

CFLAGS = -pipe -Wall -Wmissing-prototypes -Wmissing-declarations -MD -MP $(DEBUG)

CPPFLAGS = $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE -DREVISION=\"$(REVISION)\"


ifeq ($(APP_CONFERENCE_DEBUG), 1)
CPPFLAGS += -DAPP_CONFERENCE_DEBUG
endif


ifeq ($(APP_CONFERENCE_DU), 1)
CPPFLAGS += -lMagickWand
OBJS += stream.o
endif

#
# additional flag values for silence detection
#


OSARCH=$(shell uname -s)
ifeq (${OSARCH},Darwin)
SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
else
SOLINK=-shared -Xlinker -x
endif

DEPS += $(subst .o,.d,$(OBJS))

#
# targets
#

all: $(TARGET)

.PHONY: clean
clean:
    $(RM) $(OBJS) $(DEPS)

.PHONY: distclean
distclean: clean
    $(RM) $(TARGET)

#stream.o: stream.c gcc -Wall -lMagickWand stream.c

$(TARGET): $(OBJS)
    $(CC) -pg $(SOLINK) -o $@ $(OBJS)



vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o
    $(CC) $(PROFILE) -o $@ $^ -lm

install:
    $(INSTALL) -m 755 $(TARGET) $(INSTALL_MODULES_DIR)


-include $(DEPS) 
I have added the following lines...
1
2
3
4
ifeq ($(APP_CONFERENCE_DU), 1)
CPPFLAGS += -lMagickWand
OBJS += stream.o
endif
Do you know where the library is located? Does it have the same name (i.e. it should be called either libMagickWand.a or libMagickWand.so)?
Topic archived. No new replies allowed.