PDA

View Full Version : [C] Problemi compilazione e linking


Erotavlas_turbo
18-12-2009, 10:04
Salve,

ho scritto un codice C molto semplice che deve essere compilato con un parametro aggiuntivo per far collegare delle librerie esterne.
Il codice da compilare è il seguente

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();

La riga di comando che consente di compilarlo è la seguente gcc -Wall -lMagickWand main.c -o main

Se provo ad integrare questo software in un software principale più complesso quest'ultimo non funziona più...mi spiego meglio.

Credo che il problema sia dovuto alla chiamata magick_wand = NewMagickWand(); che necessità delle librerie esterne passate con il parametro -lMagickWand.

Per compilare il codice principale è presente un Makefile nel quale ho aggiunto alcune righe per includere la nuova parte di codice. Se aggiunto o tolgo l'opzione del linker -lMagickWand non vedo differenze durante la compilazione ::)
Il programma principale non parte, se provo a commentare la chiamata a NewMagickWand(); funziona correttamente...

Mi sapete dare un'aiuto?E' la prima volta che scrivo un Makefile...

Grazie

PS

Nel Makefile ci sono molte di righe di codice...riporto quelle riguardanti la compilazione.


.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)


Ho aggiunto le seguenti righe di codice...
ifeq ($(APP_CONFERENCE_DU), 1)
CPPFLAGS += -lMagickWand
OBJS += stream.o
endif