Static build of alsa-lib
Hi there,
I would like to compile an alsa application for an embedded system with no shared-libraries support. My application just needs PCM, with no plug-ins, no mixer and no midi and the application should be a standalone executable with no external dependencies, otherwise it will not work.
I tried to compile alsa-lib with static support, but without luck (-ldl is always needed in the gcc line and gcc always prints some weird warnings). Since I don't need external plugins nor ladspa, I think there should be a way to compile an application in a 100% static manner, but I still have to figure out how.
I also found this thread with a similar problem with uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
but at the end I did not understand how/if the problem was solved.
Do you think it should be possible to compile alsa-lib with no dependencies on dl? How?
Otherwise, would it be possible to write an alsa application that does not rely on alsa-lib (i.e., by using the alsa kernel APIs directly)? Has someone already tried it? Some hints?
Every hint is extremely welcome
Thanks a lot
Best regards
Andrea
____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 25 lines · Ciaccia
Hi there,
I would like to compile an alsa application for an embedded system with no shared-libraries support. My application just needs PCM, with no plug-ins, no mixer and no midi and the application should be a standalone executable with no external dependencies, otherwise it will not work.I tried to compile alsa-lib with static support, but without luck (-ldl is always needed in the gcc line and gcc always prints some weird warnings). Since I don't need external plugins nor ladspa, I think there should be a way to compile an application in a 100% static manner, but I still have to figure out how.
I also found this thread with a similar problem with uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
but at the end I did not understand how/if the problem was solved.Do you think it should be possible to compile alsa-lib with no dependencies on dl? How?
Quoted 6 lines
Otherwise, would it be possible to write an alsa application that does not rely on alsa-lib (i.e., by using the alsa kernel APIs directly)? Has someone already tried it? Some hints?
Every hint is extremely welcome
I worked on this sometime ago, and made a patch to build alsa-lib without pthread and libdl. I don't remember why this wasn't applied. IIRC, ulibc has the wrappers for pthread and libdl, so this wasn't needed at that time in the end.
Otherwise, it should work. Build with --enable-static --disable-shared, --disble-mixer, --disable-hwdep, etc.
Takashi
configure.in +17 -0
@@ -148,6 +148,23 @@ else else AC_MSG_RESULT(no) fi + +AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) +AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"]) + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi +if test "$HAVE_LIBDL" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) +fi +if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread]) +fi +AC_SUBST(ALSA_DEPLIBS) dnl Check for architecture AC_MSG_CHECKING(for architecture)
include/local.h +5 -0
@@ -36,6 +36,11 @@#include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0#endif #define _snd_config_iterator list_head
src/Makefile.am +1 -1
@@ -41,7 +41,7 @@ libasound_la_LIBADD += alisp/libalisp.la libasound_la_LIBADD += alisp/libalisp.la endif SUBDIRS += compat conf -libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la @ALSA_DEPLIBS@ libasound_la_LDFLAGS = -version-info $(COMPATNUM) $(VSYMS)
src/async.c +2 -0
@@ -151,9 +151,11 @@ int snd_async_del_handler(snd_async_handif (!list_empty (&handler->hlist)) goto _end;switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM : err =snd_pcm_async (handler->u.pcm,-1 ,1 );break ; +#endif case SND_ASYNC_HANDLER_CTL : err =snd_ctl_async (handler->u.ctl,-1 ,1 );break ;
src/conf.c +13 -3
@@ -415,12 +415,13 @@ beginning:</P>#include <stdarg.h> -#include <dlfcn.h> #include <limits.h> #include <sys/stat.h> -#include <pthread.h> #include <locale.h> #include "local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN
@@ -3080,7 +3081,9 @@ int snd_config_update_r(snd_config_t **_return 1 ; } +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_config_update_mutex =PTHREAD_MUTEX_INITIALIZER ; +#endif /** * \brief Updates #snd_config by rereading the global configuration files (if needed).
@@ -3099,9 +3102,13 @@ int snd_config_update(void) {int err; +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif err =snd_config_update_r (&snd_config, &snd_config_global_update,NULL ); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); +#endif return err; }
@@ -3128,15 +3135,18 @@ int snd_config_update_free(snd_config_up*/ int snd_config_update_free_global (void ) { +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif if (snd_config)snd_config_delete (snd_config); snd_config =NULL ;if (snd_config_global_update)snd_config_update_free (snd_config_global_update); snd_config_global_update =NULL ; +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); - +#endif /* FIXME: better to place this in another place... */ snd_dlobj_cache_cleanup ();
src/confmisc.c +4 -0
@@ -946,6 +946,8 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_naSND_DLSYM_BUILD_VERSION (snd_func_card_name,SND_CONFIG_DLSYM_VERSION_EVALUATE );#endif +#ifdef BUILD_PCM +/** * \brief Returns the pcm identification of a device. * \param dst The function puts the handle to the result configuration node
@@ -1198,6 +1200,8 @@ int snd_func_private_pcm_subdevice(snd_c#ifndef DOC_HIDDEN SND_DLSYM_BUILD_VERSION (snd_func_private_pcm_subdevice,SND_CONFIG_DLSYM_VERSION_EVALUATE );#endif + +#endif /* BUILD_PCM */ /** * \brief Copies the specified configuration node.
src/control/control.c +0 -1
@@ -47,7 +47,6 @@ and IEC958 structure.#include <string.h> #include <fcntl.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include "control_local.h"
src/control/hcontrol.c +9 -2
@@ -48,11 +48,13 @@ to reduce overhead accessing the real co#include <string.h> #include <fcntl.h> #include <sys/ioctl.h> -#include <pthread.h> #ifndef DOC_HIDDEN #define __USE_GNU#endif #include "control_local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN #define NOT_FOUND 1000000000
@@ -420,17 +422,22 @@ static void snd_hctl_sort(snd_hctl_t *hcstatic void snd_hctl_sort (snd_hctl_t *hctl) {unsigned int k; +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t sync_lock =PTHREAD_MUTEX_INITIALIZER ; +#endif assert (hctl);assert (hctl->compare);INIT_LIST_HEAD (&hctl->elems); +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&sync_lock); +#endif compare_hctl = hctl;qsort (hctl->pelems, hctl->count,sizeof (*hctl->pelems), hctl_compare); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&sync_lock); - +#endif for (k =0 ; k < hctl->count; k++)list_add_tail (&hctl->pelems[k]->list, &hctl->elems); }
src/dlmisc.c +18 -1
@@ -28,7 +28,6 @@*/ #define _GNU_SOURCE -#include <dlfcn.h> #include "list.h" #include "local.h"
@@ -53,13 +52,19 @@ void *snd_dlopen(const char *name, int mif (name ==NULL )return &snd_dlsym_start;#else +#ifdef HAVE_LIBDL if (name ==NULL ) {Dl_info dlinfo;if (dladdr (snd_dlopen, &dlinfo) >0 ) name = dlinfo.dli_fname; }#endif +#endif +#ifdef HAVE_LIBDL return dlopen (name, mode); +#else +return NULL ; +#endif }/**
@@ -76,7 +81,11 @@ int snd_dlclose(void *handle)if (handle == &snd_dlsym_start)return 0 ;#endif +#ifdef HAVE_LIBDL return dlclose (handle); +#else +return 0 ; +#endif }/**
@@ -91,6 +100,7 @@ int snd_dlclose(void *handle)*/ static int snd_dlsym_verify (void *handle,const char *name,const char *version) { +#ifdef HAVE_LIBDL int res;char *vname;
@@ -107,6 +117,9 @@ static int snd_dlsym_verify(void *handleif (res <0 )SNDERR ("unable to verify version for symbol %s" , name);return res; +#else +return 0 ; +#endif }/**
@@ -139,10 +152,14 @@ void *snd_dlsym(void *handle, const char return NULL; }#endif +#ifdef HAVE_LIBDL err =snd_dlsym_verify (handle, name, version);if (err <0 )return NULL ;return dlsym (handle, name); +#else +return NULL ; +#endif }/*
src/hwdep/hwdep.c +0 -1
@@ -33,7 +33,6 @@#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "hwdep_local.h"
src/pcm/pcm.c +0 -1
@@ -634,7 +634,6 @@ playback devices.#include <malloc.h> #include <stdarg.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include <sys/shm.h> #include <sys/mman.h>
src/pcm/pcm_hooks.c +0 -1
@@ -27,7 +27,6 @@* */ -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_generic.h"
src/pcm/pcm_ladspa.c +0 -1
@@ -33,7 +33,6 @@*/ #include <dirent.h> -#include <dlfcn.h> #include <locale.h> #include <math.h> #include "pcm_local.h"
src/pcm/pcm_meter.c +19 -2
@@ -29,11 +29,12 @@#include <byteswap.h> #include <time.h> -#include <pthread.h> -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_plugin.h" #include "iatomic.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef PIC /* entry for static linking */
@@ -42,6 +43,20 @@ const char *_snd_module_pcm_meter = ""; #ifndef DOC_HIDDEN #define FREQUENCY 50 + +#ifndef HAVE_LIBPTHREAD +#define pthread_mutex_trylock(x) 1 +#define pthread_mutex_lock(x) +#define pthread_mutex_unlock(x) +#define pthread_mutex_init(x, y) +#define pthread_mutex_destroy(x) +#define pthread_cond_init(x, y) +#define pthread_cond_destroy(x) +#define pthread_cond_wait(x, y) +#define pthread_cond_signal(x) +#define pthread_create(a, b, c, d) +#define pthread_join(a, b) +#endif struct _snd_pcm_scope { int enabled;
@@ -62,10 +77,12 @@ typedef struct _snd_pcm_meter {int closed;int running;atomic_t reset; +#ifdef HAVE_LIBPTHREAD pthread_t thread;pthread_mutex_t update_mutex;pthread_mutex_t running_mutex;pthread_cond_t running_cond; +#endif struct timespec delay;void *dl_handle; } snd_pcm_meter_t;
src/pcm/pcm_rate.c +0 -1
@@ -29,7 +29,6 @@*/ #include <inttypes.h> #include <byteswap.h> -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h"
src/pcm/pcm_share.c +21 -2
@@ -36,8 +36,10 @@#include <sys/socket.h> #include <sys/poll.h> #include <sys/shm.h> +#include "pcm_local.h" +#ifdef HAVE_LIBPTHREAD #include <pthread.h> -#include "pcm_local.h" +#endif #ifndef PIC /* entry for static linking */
@@ -47,8 +49,11 @@ const char *_snd_module_pcm_share = "";#ifndef DOC_HIDDEN static LIST_HEAD (snd_pcm_share_slaves); +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_pcm_share_slaves_mutex =PTHREAD_MUTEX_INITIALIZER ; - +#endif + +#ifdef HAVE_LIBPTHREAD #ifdef MUTEX_DEBUG #define Pthread_mutex_lock (mutex) \ char *snd_pcm_share_slaves_mutex_holder;
@@ -71,6 +76,18 @@ do { \#define Pthread_mutex_lock (mutex) pthread_mutex_lock(mutex)#define Pthread_mutex_unlock (mutex) pthread_mutex_unlock(mutex)#endif +#else /* !HAVE_LIBPTHREAD */ +#define Pthread_mutex_lock (mutex) +#define Pthread_mutex_unlock (mutex) +#define pthread_create (a, b, c, d) +#define pthread_join (a, b) +#define pthread_mutex_init (a, b) +#define pthread_mutex_destroy (a) +#define pthread_cond_init (a, b) +#define pthread_cond_destroy (a) +#define pthread_cond_wait (a, b) +#define pthread_cond_signal (a) +#endif /* HAVE_LIBPTHREAD */ typedef struct { struct list_head clients;
@@ -91,12 +108,14 @@ typedef struct {snd_pcm_uframes_t hw_ptr;int poll[2 ];int polling; +#ifdef HAVE_LIBPTHREAD pthread_t thread;pthread_mutex_t mutex;#ifdef MUTEX_DEBUG char *mutex_holder;#endif pthread_cond_t poll_cond; +#endif } snd_pcm_share_slave_t; typedef struct {
src/rawmidi/rawmidi.c +0 -1
@@ -139,7 +139,6 @@ This example shows open and read/write r#include <stdarg.h> #include <unistd.h> #include <string.h> -#include <dlfcn.h> #include "rawmidi_local.h" /**
src/seq/seq.c +0 -1
@@ -777,7 +777,6 @@ void event_filter(snd_seq_t *seq, snd_se*/ -#include <dlfcn.h> #include <sys/poll.h> #include "seq_local.h"
src/timer/timer.c +0 -1
@@ -72,7 +72,6 @@ This example shows opening a timer devic#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <signal.h> #include <sys/ioctl.h> #include "timer_local.h"
src/timer/timer_query.c +0 -1
@@ -31,7 +31,6 @@#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "timer_local.h"
utils/alsa.pc.in +1 -1
@@ -8,7 +8,7 @@ Version: @VERSION@ Version: @VERSION@ Requires: Libs: -L${libdir} -lasound -Libs.private: -lm -ldl -lpthread +Libs.private: @ALSA_DEPLIBS@ # -I${includedir}/alsa below is just for backward compatibility # (it was set so mistakely in the older version) Cflags: -I${includedir} -I${includedir}/alsa
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Fri, 16 Mar 2007 15:18:04 +0100,
Quoted 35 lines · I wrote:
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 25 lines · Ciaccia
Hi there,
I would like to compile an alsa application for an embedded system with no shared-libraries support. My application just needs PCM, with no plug-ins, no mixer and no midi and the application should be a standalone executable with no external dependencies, otherwise it will not work.I tried to compile alsa-lib with static support, but without luck (-ldl is always needed in the gcc line and gcc always prints some weird warnings). Since I don't need external plugins nor ladspa, I think there should be a way to compile an application in a 100% static manner, but I still have to figure out how.
I also found this thread with a similar problem with uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
but at the end I did not understand how/if the problem was solved.Do you think it should be possible to compile alsa-lib with no dependencies on dl? How?
Quoted 6 lines
Otherwise, would it be possible to write an alsa application that does not rely on alsa-lib (i.e., by using the alsa kernel APIs directly)? Has someone already tried it? Some hints?
Every hint is extremely welcome
Quoted 7 lines
I worked on this sometime ago, and made a patch to build alsa-lib without pthread and libdl. I don't remember why this wasn't applied. IIRC, ulibc has the wrappers for pthread and libdl, so this wasn't needed at that time in the end.
Otherwise, it should work. Build with --enable-static --disable-shared, --disble-mixer, --disable-hwdep, etc.
... oh, not perfectly if really no pcm plugin is used.
The patch below fixes the build problem. Already applied to HG tree.
Takashi
configure.in +1 -0
@@ -371,6 +371,7 @@ fi dnl Create PCM plugin symbol list for static library rm -f "$srcdir"/src/pcm/pcm_symbols_list.c +touch "$srcdir"/src/pcm/pcm_symbols_list.c for t in $PCM_PLUGIN_LIST; do if eval test \$build_pcm_$t = yes; then echo \&_snd_module_pcm_$t, >> "$srcdir"/src/pcm/pcm_symbols_list.c
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Hi Takashi,
Thanks for the answer. To I need both the patches or just the first one? Which alsa-lib release should I use with the patch, 1.0.13?
PS: sorry, what is the HG tree?
Quoted 26 lines · --- Takashi Iwai
At Fri, 16 Mar 2007 15:18:04 +0100,
Quoted 6 lines · I wrote:
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 3 lines · Ciaccia
Hi there,
I would like to compile an alsa application foran
Quoted 1 line
Quoted 1 line
embedded system with no shared-libraries
support. My
Quoted 1 line
Quoted 1 line
application just needs PCM, with no plug-ins, no
mixer
Quoted 1 line
Quoted 1 line
and no midi and the application should be a
standalone
Quoted 1 line
Quoted 1 line
executable with no external dependencies,
otherwise it
Quoted 3 lines
Quoted 3 lines
will not work.
I tried to compile alsa-lib with static support,
but
Quoted 1 line
Quoted 1 line
without luck (-ldl is always needed in the gcc
line
Quoted 1 line
Quoted 1 line
and gcc always prints some weird warnings).
Since I
Quoted 1 line
Quoted 1 line
don't need external plugins nor ladspa, I think
Quoted 11 lines
there
Quoted 1 line
Quoted 1 line
should be a way to compile an application in a
100%
Quoted 1 line
Quoted 1 line
static manner, but I still have to figure out
how.
Quoted 2 lines
Quoted 2 lines
I also found this thread with a similar problem
with
Quoted 2 lines
Quoted 2 lines
uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
Quoted 49 lines
Quoted 1 line
Quoted 1 line
but at the end I did not understand how/if the
problem
Quoted 3 lines
Quoted 3 lines
was solved.
Do you think it should be possible to compile
alsa-lib
Quoted 4 lines
Quoted 4 lines
with no dependencies on dl? How?
Otherwise, would it be possible to write an alsa
application that does not rely on alsa-lib(i.e.,
Quoted 1 line
Quoted 1 line
by using the alsa kernel APIs directly)? Has
someone
Quoted 5 lines
Quoted 3 lines
already tried it? Some hints?
Every hint is extremely welcome
I worked on this sometime ago, and made a patch to
build alsa-lib
Quoted 1 line
without pthread and libdl. I don't remember why
this wasn't applied.
Quoted 1 line
IIRC, ulibc has the wrappers for pthread and
libdl, so this wasn't
Quoted 3 lines
needed at that time in the end.
Otherwise, it should work. Build with
--enable-static
Quoted 1 line
--disable-shared, --disble-mixer, --disable-hwdep,
etc.
... oh, not perfectly if really no pcm plugin is
used.
The patch below fixes the build problem. Already
applied to HG tree.Takashi
diff -r
f1203eb7eb48configure.inconfigure.in +0
-0@@ -371,6 +371,7 @@ fi dnl Create PCM plugin symbol list for staticlibrary
rm -f "$srcdir"/src/pcm/pcm_symbols_list.c
+touch "$srcdir"/src/pcm/pcm_symbols_list.c
for t in $PCM_PLUGIN_LIST; do
if eval test \$build_pcm_$t = yes; then
Quoted 3 lines
echo \&_snd_module_pcm_$t, >>"$srcdir"/src/pcm/pcm_symbols_list.c
____________________________________________________________________________________
Don't get soaked. Take a quick peek at the forecast with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Fri, 16 Mar 2007 08:11:20 -0700 (PDT),
Quoted 4 lines · Ciaccia
Hi Takashi,
Thanks for the answer. To I need both the patches or just the first one?
The second one is for the fix to build without any extra pcm plugins (i.e. --with-pcm-plugins=hw or so).
Quoted 2 lines
Which alsa-lib release should I
use with the patch, 1.0.13?
Better to use the latest HG version.
Quoted 1 line
PS: sorry, what is the HG tree?
HG (Mercurial) is what we are currently using as the source tree management. See www.alsa-project.org download section.
The daily snapshot tarballs are available at
ftp://ftp.suse.com/pub/projects/alsa/snapshot/
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Hi Takashi,
I downloaded the last snapshot from hg (alsa-lib-hg20070317) and I applied the patch you included in your email. Then I configured alsa-lib as following:
./configure --enable-static --disable-shared
--disable-mixer --disable-hwdep --disable-rawmidi
--disable-seq --disable-instr --disable-alisp
-with-pcm-plugins=no
I just need PCM, so I disable all the packages but PCM. Then I compiled my mini application (just snd_pcm_open, configure it and write some data to it) with the following command-line (I'm using gcc 4.1):
$ gcc -o test test.c -L/tmp/alsa-lib-hg20070317/src/.libs/ -lasound -lm -lpthread -static
and I got the following errors/warnings:
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(control_shm.o):
In function `_snd_ctl_shm_open':/tmp/alsa-lib-hg20070317/src/control/control_shm.c:664:
warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlsym_verify':/tmp/alsa-lib-hg20070317/src/dlmisc.c:115: undefined reference to `dlsym' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlsym':/tmp/alsa-lib-hg20070317/src/dlmisc.c:159: undefined reference to `dlsym' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlclose':/tmp/alsa-lib-hg20070317/src/dlmisc.c:85: undefined reference to `dlclose' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlopen':/tmp/alsa-lib-hg20070317/src/dlmisc.c:64: undefined reference to `dlopen'
collect2: ld returned 1 exit status
Am I doing something wrong?!?
Thanks
Bye
Andrea
Quoted 21 lines · --- Takashi Iwai
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 4 lines · Ciaccia
Hi there,
I would like to compile an alsa application for an embedded system with no shared-libraries support.My
Quoted 1 line
application just needs PCM, with no plug-ins, no
mixer
Quoted 1 line
and no midi and the application should be a
standalone
Quoted 1 line
executable with no external dependencies,
otherwise it
Quoted 3 lines
will not work.
I tried to compile alsa-lib with static support,
but
Quoted 1 line
without luck (-ldl is always needed in the gcc
line
Quoted 1 line
and gcc always prints some weird warnings). Since
I
Quoted 11 lines
Quoted 1 line
don't need external plugins nor ladspa, I think
there
Quoted 1 line
should be a way to compile an application in a
100%
Quoted 3 lines
static manner, but I still have to figure out how.
I also found this thread with a similar problem
with
Quoted 2 lines
uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
Quoted 161 lines
Quoted 1 line
but at the end I did not understand how/if the
problem
Quoted 3 lines
was solved.
Do you think it should be possible to compile
alsa-lib
Quoted 5 lines
with no dependencies on dl? How?
Otherwise, would it be possible to write an alsa application that does not rely on alsa-lib (i.e., by using the alsa kernel APIs directly)? Has
someone
Quoted 3 lines
already tried it? Some hints?
Every hint is extremely welcome
I worked on this sometime ago, and made a patch to build alsa-lib
without pthread and libdl. I don't remember why this wasn't applied.
IIRC, ulibc has the wrappers for pthread and libdl, so this wasn't
needed at that time in the end.Otherwise, it should work. Build with --enable-static
--disable-shared, --disble-mixer, --disable-hwdep, etc.Takashi
diff -r
f1203eb7eb48configure.inconfigure.in +17
-0@@ -148,6 +148,23 @@ else else AC_MSG_RESULT(no) fi + +AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) +AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"]) + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi +if test "$HAVE_LIBDL" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) +fi +if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread]) +fi +AC_SUBST(ALSA_DEPLIBS)dnl Check for architecture
AC_MSG_CHECKING(for architecture)
diff -rf1203eb7eb48include/local.hinclude/local.h +5
-0@@ -36,6 +36,11 @@#include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0#endif #define _snd_config_iterator list_headdiff -r
f1203eb7eb48src/Makefile.amsrc/Makefile.am +0
-0@@ -41,7 +41,7 @@ libasound_la_LIBADD +=alisp/libalisp.la
libasound_la_LIBADD+= alisp/libalisp.la
endif
SUBDIRS += compat confsrc/Makefile.am +1
-2-libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la@ALSA_DEPLIBS@
libasound_la_LDFLAGS= -version-info $(COMPATNUM)
$(VSYMS)diff -r
f1203eb7eb48src/async.csrc/async.c +0
-0@@ -151,9 +151,11 @@ intsnd_async_del_handler(snd_async_hand
src/async.c +2
-0if (!list_empty (&handler->hlist)) goto _end;switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM : err =snd_pcm_async (handler->u.pcm,-1 ,1 );break ; +#endif case SND_ASYNC_HANDLER_CTL : err =snd_ctl_async (handler->u.ctl,-1 ,1 );break ;diff -r
f1203eb7eb48src/conf.csrc/conf.c +3
-2@@ -415,12 +415,13 @@ beginning:</P>#include <stdarg.h> -#include <dlfcn.h> #include <limits.h> #include <sys/stat.h> -#include <pthread.h> #include <locale.h> #include "local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN @@ -3080,7 +3081,9 @@ intsnd_config_update_r(snd_config_t **_
src/conf.c +1
-0return 1 ; } +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_config_update_mutex =
PTHREAD_MUTEX_INITIALIZER;
+#endif/**
* \brief Updates #snd_config by rereading the
global configuration files (if needed).src/conf.c +4
-0@@ -3099,9 +3102,13 @@ int snd_config_update(void) {int err; +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif err =snd_config_update_r (&snd_config, &snd_config_global_update,NULL ); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); +#endif return err; }@@ -3128,15 +3135,18 @@ intsnd_config_update_free(snd_config_up
*/
intsnd_config_update_free_global(void)
{
src/conf.c int snd_config_update_free(snd_config_up · line 3146
Quoted 9 lines
src/conf.c +2
-0+#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif if (snd_config)snd_config_delete (snd_config); snd_config =NULL ;if (snd_config_global_update)snd_config_update_free (snd_config_global_update); snd_config_global_update =NULL ;
=== message truncated ===
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Sat, 17 Mar 2007 03:13:06 -0700 (PDT),
Quoted 48 lines · Ciaccia
Hi Takashi,
I downloaded the last snapshot from hg (alsa-lib-hg20070317) and I applied the patch you included in your email. Then I configured alsa-lib as following:./configure --enable-static --disable-shared --disable-mixer --disable-hwdep --disable-rawmidi --disable-seq --disable-instr --disable-alisp -with-pcm-plugins=no
I just need PCM, so I disable all the packages but PCM. Then I compiled my mini application (just
snd_pcm_open, configure it and write some data to it) with the following command-line (I'm using gcc 4.1):$ gcc -o test test.c(quoted diff) +0
-2-L/tmp/alsa-lib-hg20070317/src/.libs/ -lasound -lm -lpthread -staticand I got the following errors/warnings:
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(control_shm.o):
In function `_snd_ctl_shm_open':/tmp/alsa-lib-hg20070317/src/control/control_shm.c:664:
warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlsym_verify':/tmp/alsa-lib-hg20070317/src/dlmisc.c:115: undefined reference to `dlsym' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlsym':/tmp/alsa-lib-hg20070317/src/dlmisc.c:159: undefined reference to `dlsym' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlclose':/tmp/alsa-lib-hg20070317/src/dlmisc.c:85: undefined reference to `dlclose' /tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
In function `snd_dlopen':/tmp/alsa-lib-hg20070317/src/dlmisc.c:64: undefined reference to `dlopen'
collect2: ld returned 1 exit status
Quoted 1 line
Am I doing something wrong?!?
No. But, as you find in my patch, the configure checks whether libdl and pthread are available and doesn't provide the flag to disable them. That's why these functions are still there.
Note that the concept of dynamic loading doesn't conflict with static library. So, unconditionally disabling libdl with a static lib is a bad idea. Rather we can add options to disable libdl and libpthread, not only detecting them.
Takashi
Quoted 215 lines
Thanks
Bye
AndreaQuoted 21 lines · --- Takashi Iwai
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 4 lines · Ciaccia
Hi there,
I would like to compile an alsa application for an embedded system with no shared-libraries support.My
Quoted 1 line
application just needs PCM, with no plug-ins, no
mixer
Quoted 1 line
and no midi and the application should be a
standalone
Quoted 1 line
executable with no external dependencies,
otherwise it
Quoted 3 lines
will not work.
I tried to compile alsa-lib with static support,
but
Quoted 1 line
without luck (-ldl is always needed in the gcc
line
Quoted 1 line
and gcc always prints some weird warnings). Since
I
Quoted 11 lines
Quoted 1 line
don't need external plugins nor ladspa, I think
there
Quoted 1 line
should be a way to compile an application in a
100%
Quoted 3 lines
static manner, but I still have to figure out how.
I also found this thread with a similar problem
with
Quoted 2 lines
uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
Quoted 161 lines
Quoted 1 line
but at the end I did not understand how/if the
problem
Quoted 3 lines
was solved.
Do you think it should be possible to compile
alsa-lib
Quoted 5 lines
with no dependencies on dl? How?
Otherwise, would it be possible to write an alsa application that does not rely on alsa-lib (i.e., by using the alsa kernel APIs directly)? Has
someone
Quoted 3 lines
already tried it? Some hints?
Every hint is extremely welcome
I worked on this sometime ago, and made a patch to build alsa-lib
without pthread and libdl. I don't remember why this wasn't applied.
IIRC, ulibc has the wrappers for pthread and libdl, so this wasn't
needed at that time in the end.Otherwise, it should work. Build with --enable-static
--disable-shared, --disble-mixer, --disable-hwdep, etc.Takashi
diff -r
f1203eb7eb48configure.inconfigure.in +17
-0@@ -148,6 +148,23 @@ else else AC_MSG_RESULT(no) fi + +AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) +AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"]) + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi +if test "$HAVE_LIBDL" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) +fi +if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread]) +fi +AC_SUBST(ALSA_DEPLIBS)dnl Check for architecture
AC_MSG_CHECKING(for architecture)
diff -rf1203eb7eb48include/local.hinclude/local.h +5
-0@@ -36,6 +36,11 @@#include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0#endif #define _snd_config_iterator list_headdiff -r
f1203eb7eb48src/Makefile.amsrc/Makefile.am +0
-0@@ -41,7 +41,7 @@ libasound_la_LIBADD +=alisp/libalisp.la
libasound_la_LIBADD+= alisp/libalisp.la
endif
SUBDIRS += compat confsrc/Makefile.am +1
-2-libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la@ALSA_DEPLIBS@
libasound_la_LDFLAGS= -version-info $(COMPATNUM)
$(VSYMS)diff -r
f1203eb7eb48src/async.csrc/async.c +0
-0@@ -151,9 +151,11 @@ intsnd_async_del_handler(snd_async_hand
src/async.c +2
-0if (!list_empty (&handler->hlist)) goto _end;switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM : err =snd_pcm_async (handler->u.pcm,-1 ,1 );break ; +#endif case SND_ASYNC_HANDLER_CTL : err =snd_ctl_async (handler->u.ctl,-1 ,1 );break ;diff -r
f1203eb7eb48src/conf.csrc/conf.c +3
-2@@ -415,12 +415,13 @@ beginning:</P>#include <stdarg.h> -#include <dlfcn.h> #include <limits.h> #include <sys/stat.h> -#include <pthread.h> #include <locale.h> #include "local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN @@ -3080,7 +3081,9 @@ intsnd_config_update_r(snd_config_t **_
src/conf.c +1
-0return 1 ; } +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_config_update_mutex =
PTHREAD_MUTEX_INITIALIZER;
+#endif/**
* \brief Updates #snd_config by rereading the
global configuration files (if needed).src/conf.c +4
-0@@ -3099,9 +3102,13 @@ int snd_config_update(void) {int err; +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif err =snd_config_update_r (&snd_config, &snd_config_global_update,NULL ); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); +#endif return err; }@@ -3128,15 +3135,18 @@ intsnd_config_update_free(snd_config_up
*/
intsnd_config_update_free_global(void)
{src/conf.c int snd_config_update_free(snd_config_up · line 3146
Quoted 9 lines
src/conf.c +2
-0+#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif if (snd_config)snd_config_delete (snd_config); snd_config =NULL ;if (snd_config_global_update)snd_config_update_free (snd_config_global_update); snd_config_global_update =NULL ;=== message truncated ===
Quoted 5 lines
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 1 line · Takashi Iwai
No. But, as you find in my patch, the configure checks [ ... ]
Takashi, Jaroslav, list: something isnt right with that moderation interface on sourceforge. This was one of 3 messages I approved in one go yet this is the only one that has made it onto the list until now. I even have a message from Rask Ingemann Lambertsen in my inbox, sent yesterday, that I havent seen appear on the list either (yet, but I doubt its going to show up).
If sourceforge keeps bugging/lagging like this, moderation may not be a solution either.
Rene.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Hi Takashi,
It's clear that the concept of dynamic loading doesn't conflict with static library, I think my original question was not completely clear.
I would like to port a sound application (just PCM, no midi or other stuff) to an embedded system. The core of this embedded system is a Cirrus EP9302 ARM processor, which supports hardware floating points.
ARM processors have several ABIs (EABI, OABI, ???) and programs compiled using one ABI are not linkable (neither at compile time, nor at run time) with other binaries, because of the different format. This is a problem for binary distributions (such as Debian), since the same binary does not work on all ARM architectures.
For a reason I really don't understand, EP9302 hardware floating point binaries only work when compiled with -static (don't ask me why...), and therefore I wanted to have a "static" (=without shared libraries) ALSA application. If this would not be possible I can always use OSS (which does not requires shared objects to be loaded at run time), but I still think it should be possible to develop ALSA applications for architectures where dynamic loading is not available...
Is there a way to achieve this?
Thanks again
Andrea
Quoted 23 lines · --- Takashi Iwai
At Sat, 17 Mar 2007 03:13:06 -0700 (PDT),
Quoted 5 lines · Ciaccia
Hi Takashi,
I downloaded the last snapshot from hg (alsa-lib-hg20070317) and I applied the patch you included in your email. Then I configured alsa-libas
Quoted 11 lines
following:
./configure --enable-static --disable-shared --disable-mixer --disable-hwdep --disable-rawmidi --disable-seq --disable-instr --disable-alisp -with-pcm-plugins=no
I just need PCM, so I disable all the packages but PCM. Then I compiled my mini application (just
snd_pcm_open, configure it and write some data toit)
Quoted 1 line
with the following command-line (I'm using gcc
4.1):
Quoted 1 line
Quoted 8 lines
Quoted 7 lines
$ gcc -o test test.c(quoted diff) +0
-2-L/tmp/alsa-lib-hg20070317/src/.libs/ -lasound -lm -lpthread -staticand I got the following errors/warnings:
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(control_shm.o):
Quoted 3 lines
Quoted 2 lines
In function `_snd_ctl_shm_open':
/tmp/alsa-lib-hg20070317/src/control/control_shm.c:664:
Quoted 7 lines
Quoted 1 line
warning: Using 'gethostbyname' in statically
linked
Quoted 1 line
applications requires at runtime the shared
libraries
Quoted 2 lines
from the glibc version used for linking
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
Quoted 6 lines
Quoted 2 lines
In function `snd_dlsym_verify':
/tmp/alsa-lib-hg20070317/src/dlmisc.c:115:undefined
Quoted 2 lines
reference to `dlsym'
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
Quoted 6 lines
Quoted 2 lines
In function `snd_dlsym':
/tmp/alsa-lib-hg20070317/src/dlmisc.c:159:undefined
Quoted 2 lines
reference to `dlsym'
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
Quoted 6 lines
Quoted 2 lines
In function `snd_dlclose':
/tmp/alsa-lib-hg20070317/src/dlmisc.c:85:undefined
Quoted 2 lines
reference to `dlclose'
/tmp/alsa-lib-hg20070317/src/.libs//libasound.a(dlmisc.o):
Quoted 60 lines
Quoted 2 lines
In function `snd_dlopen':
/tmp/alsa-lib-hg20070317/src/dlmisc.c:64:undefined
Quoted 4 lines
reference to `dlopen'
collect2: ld returned 1 exit statusAm I doing something wrong?!?
No. But, as you find in my patch, the configure checks whether libdl
and pthread are available and doesn't provide the flag to disable
them. That's why these functions are still there.Note that the concept of dynamic loading doesn't conflict with static
library. So, unconditionally disabling libdl with a static lib is a
bad idea. Rather we can add options to disable libdl and libpthread,
not only detecting them.Takashi
Quoted 12 lines
Thanks
Bye
AndreaQuoted 5 lines · --- Takashi Iwai
At Fri, 16 Mar 2007 06:17:00 -0700 (PDT),
Quoted 3 lines · Ciaccia
Hi there,
I would like to compile an alsa applicationfor an
Quoted 1 line
Quoted 1 line
Quoted 1 line
embedded system with no shared-libraries
support.
Quoted 2 lines
Quoted 2 lines
My
Quoted 1 line
application just needs PCM, with no plug-ins,
no
Quoted 8 lines
Quoted 8 lines
mixer
Quoted 1 line
and no midi and the application should be a
standalone
Quoted 1 line
executable with no external dependencies,
otherwise it
Quoted 3 lines
will not work.
I tried to compile alsa-lib with static
support,
Quoted 4 lines
Quoted 4 lines
but
Quoted 1 line
without luck (-ldl is always needed in the gcc
line
Quoted 1 line
and gcc always prints some weird warnings).
Since
Quoted 2 lines
Quoted 2 lines
I
Quoted 1 line
don't need external plugins nor ladspa, I
think
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
there
Quoted 1 line
should be a way to compile an application in a
100%
Quoted 1 line
static manner, but I still have to figure out
how.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I also found this thread with a similar
problem
Quoted 5 lines
Quoted 4 lines
with
Quoted 2 lines
uClinux
http://www.mail-archive.com/[email protected]/msg18253.html
Quoted 66 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
but at the end I did not understand how/if the
problem
Quoted 3 lines
was solved.
Do you think it should be possible to compile
alsa-lib
Quoted 3 lines
with no dependencies on dl? How?
Otherwise, would it be possible to write an
alsa
Quoted 1 line
Quoted 1 line
Quoted 1 line
application that does not rely on alsa-lib
(i.e.,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
by using the alsa kernel APIs directly)? Has
someone
Quoted 3 lines
already tried it? Some hints?
Every hint is extremely welcome
I worked on this sometime ago, and made a patch
to
Quoted 4 lines
Quoted 4 lines
build alsa-lib
without pthread and libdl. I don't remember why
this wasn't applied.
IIRC, ulibc has the wrappers for pthread andlibdl,
Quoted 6 lines
Quoted 6 lines
so this wasn't
needed at that time in the end.Otherwise, it should work. Build with
--enable-static
--disable-shared, --disble-mixer,--disable-hwdep,
Quoted 7 lines
Quoted 7 lines
etc.
Takashi
diff -r
f1203eb7eb48configure.in
--- a/configure.in Tue Mar 13 10:44:28 2007+0100
Quoted 1 line
Quoted 1 line
+++ b/configure.in Fri Mar 16 15:07:51 2007
+0100
Quoted 24 lines
Quoted 24 lines
configure.in +17
-0@@ -148,6 +148,23 @@ else else AC_MSG_RESULT(no) fi + +AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) +AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"]) + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi +if test "$HAVE_LIBDL" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) +fi +if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread]) +fi +AC_SUBST(ALSA_DEPLIBS)
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
dnl Check for architecture
AC_MSG_CHECKING(for architecture)
=== message truncated ===
____________________________________________________________________________________
Don't get soaked. Take a quick peek at the forecast with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Tue, 20 Mar 2007 08:13:41 -0700 (PDT),
Quoted 30 lines · Ciaccia
Hi Takashi,
It's clear that the concept of dynamic loading doesn't conflict with static library, I think my original question was not completely clear.I would like to port a sound application (just PCM, no midi or other stuff) to an embedded system. The core of this embedded system is a Cirrus EP9302 ARM processor, which supports hardware floating points.
ARM processors have several ABIs (EABI, OABI, ???) and programs compiled using one ABI are not linkable (neither at compile time, nor at run time) with other binaries, because of the different format. This is a problem for binary distributions (such as Debian), since the same binary does not work on all ARM architectures.
For a reason I really don't understand, EP9302 hardware floating point binaries only work when compiled with -static (don't ask me why...), and therefore I wanted to have a "static" (=without shared libraries) ALSA application. If this would not be possible I can always use OSS (which does not requires shared objects to be loaded at run time), but I still think it should be possible to develop ALSA applications for architectures where dynamic loading is not available...
Quoted 1 line
Is there a way to achieve this?
Sure, what I meant is that the patch had no function to disable the libdl and libpthread explicitly but only checked. The new patch below, for example, can give you options --with-libdl and --with-pthread. For disabling libdl, pass --with-libdl=no.
If this works for you, I'll apply it to the upstream.
Takashi
Makefile.am +4 -1
@@ -1,4 +1,7 @@ SUBDIRS=doc include src modules -SUBDIRS=doc include src modules +SUBDIRS=doc include src +if BUILD_MODULES +SUBDIRS += modules +endif if BUILD_PCM_PLUGIN_SHM SUBDIRS += aserver endif
configure.in +53 -0
65 lines not on this page · raw message
include/local.h +5 -0
@@ -36,6 +36,11 @@#include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0#endif #define _snd_config_iterator list_head
src/Makefile.am +1 -1
@@ -41,7 +41,7 @@ libasound_la_LIBADD += alisp/libalisp.la libasound_la_LIBADD += alisp/libalisp.la endif SUBDIRS += compat conf -libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la @ALSA_DEPLIBS@ libasound_la_LDFLAGS = -version-info $(COMPATNUM) $(VSYMS)
src/async.c +2 -0
@@ -151,9 +151,11 @@ int snd_async_del_handler(snd_async_handif (!list_empty (&handler->hlist)) goto _end;switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM : err =snd_pcm_async (handler->u.pcm,-1 ,1 );break ; +#endif case SND_ASYNC_HANDLER_CTL : err =snd_ctl_async (handler->u.ctl,-1 ,1 );break ;
src/conf.c +13 -3
@@ -415,12 +415,13 @@ beginning:</P>#include <stdarg.h> -#include <dlfcn.h> #include <limits.h> #include <sys/stat.h> -#include <pthread.h> #include <locale.h> #include "local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN
@@ -3080,7 +3081,9 @@ int snd_config_update_r(snd_config_t **_return 1 ; } +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_config_update_mutex =PTHREAD_MUTEX_INITIALIZER ; +#endif /** * \brief Updates #snd_config by rereading the global configuration files (if needed).
@@ -3099,9 +3102,13 @@ int snd_config_update(void) {int err; +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif err =snd_config_update_r (&snd_config, &snd_config_global_update,NULL ); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); +#endif return err; }
@@ -3128,15 +3135,18 @@ int snd_config_update_free(snd_config_up*/ int snd_config_update_free_global (void ) { +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&snd_config_update_mutex); +#endif if (snd_config)snd_config_delete (snd_config); snd_config =NULL ;if (snd_config_global_update)snd_config_update_free (snd_config_global_update); snd_config_global_update =NULL ; +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&snd_config_update_mutex); - +#endif /* FIXME: better to place this in another place... */ snd_dlobj_cache_cleanup ();
src/confmisc.c +4 -0
@@ -946,6 +946,8 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_naSND_DLSYM_BUILD_VERSION (snd_func_card_name,SND_CONFIG_DLSYM_VERSION_EVALUATE );#endif +#ifdef BUILD_PCM +/** * \brief Returns the pcm identification of a device. * \param dst The function puts the handle to the result configuration node
@@ -1198,6 +1200,8 @@ int snd_func_private_pcm_subdevice(snd_c#ifndef DOC_HIDDEN SND_DLSYM_BUILD_VERSION (snd_func_private_pcm_subdevice,SND_CONFIG_DLSYM_VERSION_EVALUATE );#endif + +#endif /* BUILD_PCM */ /** * \brief Copies the specified configuration node.
src/control/control.c +0 -1
@@ -47,7 +47,6 @@ and IEC958 structure.#include <string.h> #include <fcntl.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include "control_local.h"
src/control/hcontrol.c +9 -2
@@ -48,11 +48,13 @@ to reduce overhead accessing the real co#include <string.h> #include <fcntl.h> #include <sys/ioctl.h> -#include <pthread.h> #ifndef DOC_HIDDEN #define __USE_GNU#endif #include "control_local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN #define NOT_FOUND 1000000000
@@ -420,17 +422,22 @@ static void snd_hctl_sort(snd_hctl_t *hcstatic void snd_hctl_sort (snd_hctl_t *hctl) {unsigned int k; +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t sync_lock =PTHREAD_MUTEX_INITIALIZER ; +#endif assert (hctl);assert (hctl->compare);INIT_LIST_HEAD (&hctl->elems); +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock (&sync_lock); +#endif compare_hctl = hctl;qsort (hctl->pelems, hctl->count,sizeof (*hctl->pelems), hctl_compare); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock (&sync_lock); - +#endif for (k =0 ; k < hctl->count; k++)list_add_tail (&hctl->pelems[k]->list, &hctl->elems); }
src/dlmisc.c +23 -4
@@ -28,7 +28,6 @@*/ #define _GNU_SOURCE -#include <dlfcn.h> #include "list.h" #include "local.h"
@@ -53,13 +52,19 @@ void *snd_dlopen(const char *name, int mif (name ==NULL )return &snd_dlsym_start;#else +#ifdef HAVE_LIBDL if (name ==NULL ) {Dl_info dlinfo;if (dladdr (snd_dlopen, &dlinfo) >0 ) name = dlinfo.dli_fname; }#endif +#endif +#ifdef HAVE_LIBDL return dlopen (name, mode); +#else +return NULL ; +#endif }/**
@@ -76,7 +81,11 @@ int snd_dlclose(void *handle)if (handle == &snd_dlsym_start)return 0 ;#endif +#ifdef HAVE_LIBDL return dlclose (handle); +#else +return 0 ; +#endif }/**
@@ -91,6 +100,7 @@ int snd_dlclose(void *handle)*/ static int snd_dlsym_verify (void *handle,const char *name,const char *version) { +#ifdef HAVE_LIBDL int res;char *vname;
@@ -107,6 +117,9 @@ static int snd_dlsym_verify(void *handleif (res <0 )SNDERR ("unable to verify version for symbol %s" , name);return res; +#else +return 0 ; +#endif }/**
@@ -139,10 +152,16 @@ void *snd_dlsym(void *handle, const char return NULL; }#endif - err =snd_dlsym_verify (handle, name, version); -if (err <0 ) -return NULL ; +#ifdef HAVE_LIBDL +if (version) { + err =snd_dlsym_verify (handle, name, version); +if (err <0 ) +return NULL ; + }return dlsym (handle, name); +#else +return NULL ; +#endif }/*
src/hwdep/hwdep.c +0 -1
@@ -33,7 +33,6 @@#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "hwdep_local.h"
src/mixer/simple_abst.c +2 -2
@@ -82,14 +82,14 @@ static int try_open(snd_mixer_class_t *cfree (xlib);return -ENXIO ; } - event_func =dlsym (h,"alsa_mixer_simple_event" ); + event_func =snd_dlsym (h,"alsa_mixer_simple_event" ,NULL );if (event_func ==NULL ) {SNDERR ("Symbol 'alsa_mixer_simple_event' was not found in '%s'" , xlib);snd_dlclose (h);free (xlib);return -ENXIO ; } - init_func =dlsym (h,"alsa_mixer_simple_init" ); + init_func =snd_dlsym (h,"alsa_mixer_simple_init" ,NULL );if (init_func ==NULL ) {SNDERR ("Symbol 'alsa_mixer_simple_init' was not found in '%s'" , xlib);snd_dlclose (h);
src/pcm/pcm.c +0 -1
@@ -634,7 +634,6 @@ playback devices.#include <malloc.h> #include <stdarg.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include <sys/shm.h> #include <sys/mman.h>
src/pcm/pcm_hooks.c +0 -1
@@ -27,7 +27,6 @@* */ -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_generic.h"
src/pcm/pcm_ladspa.c +0 -1
@@ -33,7 +33,6 @@*/ #include <dirent.h> -#include <dlfcn.h> #include <locale.h> #include <math.h> #include "pcm_local.h"
src/pcm/pcm_rate.c +1 -2
@@ -29,7 +29,6 @@*/ #include <inttypes.h> #include <byteswap.h> -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h"
@@ -1326,7 +1325,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp,free (rate);return -ENOENT ; } - open_func =dlsym (h, open_name); + open_func =snd_dlsym (h, open_name,NULL );if (! open_func) {SNDERR ("Cannot find function %s" , open_name);snd_dlclose (h);
src/rawmidi/rawmidi.c +0 -1
@@ -139,7 +139,6 @@ This example shows open and read/write r#include <stdarg.h> #include <unistd.h> #include <string.h> -#include <dlfcn.h> #include "rawmidi_local.h" /**
src/seq/seq.c +0 -1
@@ -777,7 +777,6 @@ void event_filter(snd_seq_t *seq, snd_se*/ -#include <dlfcn.h> #include <sys/poll.h> #include "seq_local.h"
src/timer/timer.c +0 -1
@@ -72,7 +72,6 @@ This example shows opening a timer devic#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <signal.h> #include <sys/ioctl.h> #include "timer_local.h"
src/timer/timer_query.c +0 -1
@@ -31,7 +31,6 @@#include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "timer_local.h"
utils/alsa.pc.in +1 -1
@@ -8,7 +8,7 @@ Version: @VERSION@ Version: @VERSION@ Requires: Libs: -L${libdir} -lasound -Libs.private: -lm -ldl -lpthread +Libs.private: @ALSA_DEPLIBS@ # -I${includedir}/alsa below is just for backward compatibility # (it was set so mistakely in the older version) Cflags: -I${includedir} -I${includedir}/alsa
Hi Takashi,
I have just tried the patch you provided me. I applied the patch and then I configured alsa-lib as following:
./configure --enable-static --disable-shared --disable-mixer --disable-hwdep --disable-rawmidi --disable-seq --disable-instr --disable-alisp --with-pcm-plugins=no --with-libdl=no --with-pthread=no
The compilation works fine, ant the static library is created. When I try to link my application to it, I get the following warning:
~/alsa $ gcc -Wall -O2 -o test test.c -L/tmp/alsa-lib-hg20070317/src/.libs/ -lasound -static
/tmp/alsa-lib-hg20070317/src/.libs/libasound.a(control_shm.o):
In function `_snd_ctl_shm_open':/tmp/alsa-lib-hg20070317/src/control/control_shm.c:664:
warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
I think we are getting closer, but I could not figure out how to exclude this from the compilation. The file control_shm.c contains only few macro #IFDEFS, and none for it.
Takashi, could you tell me why/when the pthread lib is needed? Do I need it for PCM, or is it used just for MIDI?
Last but not least, the ./configure --help does not give information about the the new switches (--with-libdl=no --with-pthread=no), shouldn't they be visible in the "help" page?
Thanks again,
Bye bye
Andrea
Quoted 201 lines · --- Takashi Iwai
At Tue, 20 Mar 2007 08:13:41 -0700 (PDT),
Quoted 3 lines · Ciaccia
Hi Takashi,
It's clear that the concept of dynamic loadingdoesn't
Quoted 4 lines
conflict with static library, I think my original question was not completely clear.
I would like to port a sound application (just
PCM, no
Quoted 1 line
midi or other stuff) to an embedded system. The
core
Quoted 2 lines
of this embedded system is a Cirrus EP9302 ARM processor, which supports hardware floating
points.
Quoted 2 lines
ARM processors have several ABIs (EABI, OABI, ???)
and
Quoted 2 lines
programs compiled using one ABI are not linkable (neither at compile time, nor at run time) with
other
Quoted 1 line
binaries, because of the different format. This is
a
Quoted 8 lines
problem for binary distributions (such as Debian), since the same binary does not work on all ARM architectures.
For a reason I really don't understand, EP9302 hardware floating point binaries only work when compiled with -static (don't ask me why...), and therefore I wanted to have a "static" (=without
shared
Quoted 2 lines
libraries) ALSA application. If this would not be possible I can always use OSS (which does not
requires
Quoted 1 line
shared objects to be loaded at run time), but I
still
Quoted 2 lines
think it should be possible to develop ALSA applications for architectures where dynamic
loading
Quoted 3 lines
is not available...
Is there a way to achieve this?
Sure, what I meant is that the patch had no function to disable the
libdl and libpthread explicitly but only checked. The new patch
below, for example, can give you options --with-libdl and
--with-pthread. For disabling libdl, pass --with-libdl=no.If this works for you, I'll apply it to the
upstream.Takashi
diff -r
6d0a999aef24Makefile.amMakefile.am +4
-1@@ -1,4 +1,7 @@ SUBDIRS=doc include src modules -SUBDIRS=doc include src modules +SUBDIRS=doc include src +if BUILD_MODULES +SUBDIRS += modules +endif if BUILD_PCM_PLUGIN_SHM SUBDIRS += aserver endifdiff -r
6d0a999aef24configure.inconfigure.in +27
-0@@ -148,6 +148,44 @@ else else AC_MSG_RESULT(no) fi + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi + +dnl Check for libdl +AC_MSG_CHECKING(for libdl) +AC_ARG_WITH(libdl, + [ --with-libdl Use libdl for plugins (default = yes)], + [ have_libdl="$withval" ], [ have_libdl="yes" ]) +if test "$have_libdl" = "yes"; then + AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) + if test "$HAVE_LIBDL" = "yes" ; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) + fi +else + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL(BUILD_MODULES, test "$HAVE_LIBDL"="yes") + +dnl Check for pthread +AC_MSG_CHECKING(for pthread) +AC_ARG_WITH(pthread, + [ --with-pthread Use pthread (default = yes)], + [ have_pthread="$withval" ], [ have_pthread="yes"])
configure.in +2
-0+if test "$have_pthread" = "yes"; then + AC_CHECK_LIB([pthread], [pthread_join],[HAVE_LIBPTHREAD="yes"])
configure.in +3
-0+ if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Havelibpthread])
configure.in +21
-0+ fi +else + AC_MSG_RESULT(no) +fi + +AC_SUBST(ALSA_DEPLIBS) dnl Check for architecture AC_MSG_CHECKING(for architecture)@@ -318,6 +356,21 @@ fi if test "$build_pcm_ioplug" = "yes"; then build_pcm_extplug="yes" +fi + +if test "$HAVE_LIBDL" != "yes"; then + build_pcm_meter="no" + build_pcm_ladspa="no" + build_pcm_pcm_ioplug="no" + build_pcm_pcm_extplug="no" +fi + +if test "$HAVE_LIBPTHREAD" != "yes"; then + build_pcm_share="no" +fi + +if test "$softfloat" != "yes"; then + build_pcm_lfloat="no" fi AM_CONDITIONAL(BUILD_PCM_PLUGIN, testx$build_pcm_plugin = xyes)
diff -r6d0a999aef24include/local.hinclude/local.h +5
-0@@ -36,6 +36,11 @@#include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0#endif #define _snd_config_iterator list_headdiff -r
6d0a999aef24src/Makefile.amsrc/Makefile.am +0
-0@@ -41,7 +41,7 @@ libasound_la_LIBADD +=alisp/libalisp.la
libasound_la_LIBADD+= alisp/libalisp.la
endif
SUBDIRS += compat confsrc/Makefile.am +1
-2-libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la@ALSA_DEPLIBS@
libasound_la_LDFLAGS= -version-info $(COMPATNUM)
$(VSYMS)diff -r
6d0a999aef24src/async.csrc/async.c +0
-0@@ -151,9 +151,11 @@ intsnd_async_del_handler(snd_async_hand
src/async.c +2
-0if (!list_empty (&handler->hlist)) goto _end;switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM : err =snd_pcm_async (handler->u.pcm,-1 ,1 );break ; +#endif case SND_ASYNC_HANDLER_CTL : err =snd_ctl_async (handler->u.ctl,-1 ,1 );break ;diff -r
6d0a999aef24src/conf.c
src/conf.c beginning:</P> · line 415
Quoted 1 line
src/conf.c +0
-0@@ -415,12 +415,13 @@ beginning:</P>
=== message truncated ===
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front