Commit 0ae2f823 authored by Emmanuel Milou's avatar Emmanuel Milou

Bug fix. dlopen uses the installation prefix ( configure ).

The previous commit brought a segmentation fault when launching the client.
When the daemon is lauched separatly, it uses a wrapper script, but it doesn't when the client start the daemon.
SO the LD_LIBRARY_PATH was ignored and the daemon couldn't find the dynamic library for the codecs.
parent 6e415c5a
sflcodecdir = ($libdir)/sflphone/codecs
bin_PROGRAMS = sflphoned
if USE_ZEROCONF
ZEROCONFDIR = zeroconf
ZEROCONFLIB = zeroconf/libzeroconf.la
......@@ -39,7 +41,8 @@ sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone
#sflphoned_LDFLAGS = -static
sflphoned_LDADD = ./libsflphone.la $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS) \
-DCODECS_DIR=\""$(sflcodecdir)"\"
# libsflphone_la_LDFLAGS= -version-info 0:1:0
......
sflcodecdir = $(prefix)/lib/sflphone/codecs/
sflcodecdir = $(libdir)/sflphone/codecs/
noinst_LTLIBRARIES = libaudio.la
noinst_PROGRAMS = libcodec_ulaw.so libcodec_alaw.so libcodec_gsm.so
......@@ -30,10 +30,10 @@ audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfge
tonegenerator.cpp codecDescriptor.cpp \
audioloop.cpp ringbuffer.cpp $(SPEEX_SOURCES_CPP)
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES)
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES) \
-DCODECS_DIR=\""$(sflcodecdir)"\"
libaudio_la_CPPFLAGS = $(SPEEX_FLAG)
noinst_HEADERS = audioloop.h common.h ringbuffer.h audiofile.h \
tonelist.h audiortp.h audiocodec.h audiolayer.h audiodevice.h \
dtmfgenerator.h tonegenerator.h \
......
How to build the codec shared libraries
---------------------------------------
CODEC_ALAW:
gcc -fPIC -g -c -Wall ulaw.cpp
-------> gives you the object file ulaw.o.
-------> option -g to include debug information
-------> option -Wall to generate warnings
-------> option -fPIC to enable position independant code generation
gcc -shared -o libcodec_ulaw.so ulaw.o -lc
-------> creates the shared library
CODEC ALAW:
idem
CODEC_GSM:
gcc -fPIC -g -c -Wall gsmcodec.cpp
gcc -shared -o -libcodec_gsm.so gsmcodec.o -lc -lgsm
-------> You need the standard library libgsm1 installed (with dev package).
REFERENCES: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
The shared library should be installed in $(libdir)/sflphone/codecs where libdir=$(PREFIX)/lib.
......@@ -35,7 +35,7 @@ AudioFile::AudioFile()
using std::cout;
using std::cerr;
void* codec = dlopen("libcodec_ulaw.so", RTLD_LAZY);
void* codec = dlopen( CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY);
if(!codec){
cerr<<"cannot load library: "<< dlerror() <<'\n';
}
......
......@@ -259,16 +259,16 @@ AudioRtpRTX::loadCodec(int payload)
switch(payload){
case 0:
handle_codec = dlopen("libcodec_ulaw.so", RTLD_LAZY);
handle_codec = dlopen( CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY);
break;
case 3:
handle_codec = dlopen("libcodec_gsm.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_gsm.so", RTLD_LAZY);
break;
case 8:
handle_codec = dlopen("libcodec_alaw.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_alaw.so", RTLD_LAZY);
break;
case 97:
handle_codec = dlopen("libcodec_ilbc.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_ilbc.so", RTLD_LAZY);
break;
}
......
......@@ -236,16 +236,16 @@ IAXVoIPLink::loadCodec(int payload)
switch(payload)
{
case 0:
handle_codec = dlopen("libcodec_ulaw.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY);
break;
case 3:
handle_codec = dlopen("libcodec_gsm.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_gsm.so", RTLD_LAZY);
break;
case 8:
handle_codec = dlopen("libcodec_alaw.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_alaw.so", RTLD_LAZY);
break;
case 97:
handle_codec = dlopen("libcodec_ilbc.so", RTLD_LAZY);
handle_codec = dlopen(CODECS_DIR "/libcodec_ilbc.so", RTLD_LAZY);
break;
}
if(!handle_codec){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment