OpenWrt Forum Archive

Topic: squeezelite compile failed: undefined reference to `pthread_mutexattr_

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi guys,
I'm tryin to compile the latest version of squeezelite as the previous version (1.5) stopps playing mp3-streams after some hours.


When running make everything looks fine until this section:

# make package/feeds/packages/squeezelite/compile V=s

...
mips-openwrt-linux-uclibc-gcc main.o slimproto.o buffer.o stream.o utils.o output.o output_alsa.o output_pa.o output_stdout.o output_pack.o decode.o flac.o pcm.o mad.o vorbis.o faad.o mpg.o -L/data/home/joky/openwrt/git-trunk/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/lib -L/data/home/joky/openwrt/git-trunk/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/lib -L/data/home/joky/openwrt/git-trunk/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/data/home/joky/openwrt/git-trunk/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib  -ldl -o squeezelite
slimproto.o: In function `wake_controller':
slimproto.c:(.text+0xa6e): undefined reference to `eventfd_write'
buffer.o: In function `buf_init':
buffer.c:(.text+0x116): undefined reference to `pthread_mutexattr_init'
buffer.c:(.text+0x11e): undefined reference to `pthread_mutexattr_setprotocol'
buffer.c:(.text+0x12e): undefined reference to `pthread_mutexattr_destroy'
stream.o: In function `stream_init':
stream.c:(.text+0x710): undefined reference to `pthread_attr_setstacksize'
stream.c:(.text+0x71c): undefined reference to `pthread_create'
stream.o: In function `stream_close':
stream.c:(.text+0x792): undefined reference to `pthread_join'
utils.o: In function `wait_readwake':
utils.c:(.text+0x2d2): undefined reference to `eventfd_read'
output_alsa.o: In function `alsa_close':
output_alsa.c:(.text+0x4): undefined reference to `snd_pcm_close'
output_alsa.c:(.text+0x20): undefined reference to `snd_strerror'
output_alsa.o: In function `alsa_open': ...

Makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=squeezelite
PKG_VERSION:=75a72d5f86e1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://squeezelite.googlecode.com/archive/
# PKG_MD5SUM:=4e6fc300c148d179cdbb5fa51ac50f6c

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/squeezelite
  SECTION:=multimedia
  CATEGORY:=Multimedia
  TITLE:=lightweight headless squeezebox emulator
  URL:=http://www.squeezelite/
  DEPENDS:= +AUDIO_SUPPORT:alsa-lib \
        +libvorbis +libflac \
        +libfaad2 +libffmpeg +libpthread
endef

define Package/squeezelite/description
 lightweight headless squeezebox emulator
endef

define Package/squeezelite/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(CP) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME) $(1)/usr/bin/
endef

$(eval $(call BuildPackage,squeezelite))

Is anything missing in the Makefile? Do I need any patch for the original Makefile?

kind regards

playing mp3-streams after some hours.

maybe the mp3 playback lib has a bug on some mp3 file ?

There are a couple of errors:
1. squeezelite does not use autotools so there is no need for

PKG_FIXUP:=autoreconf

autoreconf regenerates configure scripts. see http://en.wikipedia.org/wiki/GNU_build_system for a simple overview of which files these autotools packages use

2. You are observing errors in the link stage. You are missing some libraries.
the normal Makefile contains

LDFLAGS ?= -lasound -lpthread -lm -lrt

Your pasted output does not contain these.

uclibc does not have eventfd_write or eventfd_read

either patch squeezelite.h:
where the eventfd.h macro is
with the implementation of these 2 functions
see similar problem https://github.com/FreeRDP/FreeRDP/issues/1660 - and the links to the gentoo patches

or add them to uclibc:
like done in another project thats using uclibc: https://github.com/openembedded/oe-core … rite.patch


the first way to do it seems to work - but a ticket at squeezelite project would be better

patch and Makefiles are at: https://github.com/nakarotori/packages/tree/integrated

Edit: squeezelite seems to run, but cannot test playback, configuration because missing guide, hardware/software (squeezebox ? upnp server? dunno)

(Last edited by zloop on 16 Jul 2014, 10:39)

Hi zloop,

thanks for your fast response!

I setup a squeezebox-server, which has been released as open source by logitech, on a ubuntu machine. I use MR3020 + USB Soundcards as receivers which are cheap and be linked to play synchronous together.

I'll try to deploy a patch by myself and will try to submit a patch to the squeezelite developers!

kind regards

Okay, I got squeezebox also compiled. I added the missing macros into main.c and squeezelite.h:

--- a/main.c    2014-07-15 12:24:38.190723717 +0200
+++ b/main.c     2014-07-16 12:53:54.455872459 +0200
@@ -111,6 +111,7 @@
 #if EVENTFD
                   " EVENTFD"
 #endif
+
 #if SELFPIPE
                   " SELFPIPE"
 #endif
@@ -140,6 +141,23 @@
                   argv0);
 }

+#if EVENTFD
+#if defined(__UCLIBC__)
+
+int
+eventfd_read(int fd, eventfd_t* value)
+{
+       return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
+}
+
+int
+eventfd_write(int fd, eventfd_t value)
+{
+       return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
+}
+#endif
+#endif
+
 static void license(void) {
        printf(TITLE "\n\n"
                   "This program is free software: you can redistribute it and/or modify\n"
--- a/squeezelite.h     2014-07-15 12:24:38.190723717 +0200
+++ b/squeezelite.h      2014-07-16 12:52:43.575578071 +0200
@@ -226,6 +226,16 @@
 typedef int32_t   s32_t;
 typedef int64_t   s64_t;

+#if EVENTFD
+#if defined(__UCLIBC__)
+__BEGIN_DECLS
+typedef uint64_t eventfd_t;
+extern int eventfd_read (int __fd, eventfd_t *__value);
+extern int eventfd_write (int __fd, eventfd_t __value);
+__END_DECLS
+#endif
+#endif
+
 #define mutex_type pthread_mutex_t
 #define mutex_create(m) pthread_mutex_init(&m, NULL)
 #define mutex_create_p(m) pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); pthread_mutex_init(&m, &attr); pthread_mutexattr_destroy(&attr)

Unfortunately the Makefile from the squeezelite-package doesn't include an "install"-script. I tried a bit but failed quite miserable while trying to read other (working) Makefiles.

Can you give me an hint for the Makefile so that "make install" works properly so that the openwrt-scripts generate ipkg-packages?


Kind regards

I asked about creating a make file for squeezelite a couple of weeks ago - https://forum.openwrt.org/viewtopic.php?id=51435 but @zloop's reply was beyond me limited understanding.

Thank you @zloop for providing the package. Much appreciated.

I'll have to give this a test later this week.

the github link contains a working makefile for squeezelite

the posted squeezelite Makefile for OpenWrt had 2 errors for the install phase

1st one:

PKG_INSTALL:=1

This calls make install on the squeezelite Makefile - but there is not install rule in that package. So this is will lead to errors. Remove that line

define Package/squeezelite/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(CP) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME) $(1)/usr/bin/
endef

This fails too, because PKG_INSTALL_DIR does not exist (PKG_INSTALL :=1 failed, remember ? ^^) so you use PKG_BUILD_DIR and the location where the squeezelite executable is generated

thank you very much!
I setup a MR3020 with USB-Audio support (directly in the kernel, not as module) and removed all unnecessary  packages so it fits in the 4 Mb flash.

According to the developer it might an error in the usb-stack of ath9k or so,.. but now having the ROM precompiled with everything it's much easier to do further tests,...

regards

btw: can you somehow submit the package to the openwrt-feed?

hi @zloop,

I can't seem to find the squeezelite package/Makefile on your github anymore. Was it moved or deleted? Thanks

gray

Braklet wrote:

I can't find any Squeezelite information at https://github.com/nakarotori/packages/tree/integrated either, was it moved?

Can someone post a final working Makefile in this thread?

Thanks!

B

sorry for the late answer. Here are my files (placed in package/feeds/packages/squeezelite)


Makefile:

#
# Copyright (C) 2006-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=squeezelite
PKG_VERSION:=75a72d5f86e1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://squeezelite.googlecode.com/archive/

TARGET_LDFLAGS += -lasound -lpthread -lm -lrt

include $(INCLUDE_DIR)/package.mk

define Package/squeezelite
  SECTION:=sound
  CATEGORY:=Sound
  TITLE:=lightweight headless squeezebox emulator
  URL:=http://www.squeezelite/
  DEPENDS:= +AUDIO_SUPPORT:alsa-lib +libpthread +libevent2 +libevent2-pthreads +libvorbis +libflac +libfaad2 +libmpg123 +libmad
endef

define Package/squeezelite/description
 lightweight headless squeezebox emulator
endef

define Package/squeezelite/install
        mkdir -p $(1)/usr/bin/
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/bin/
endef

$(eval $(call BuildPackage,squeezelite))

patches/001-ulibc-eventfd.patch:

--- a/main.c    2014-07-15 12:24:38.190723717 +0200
+++ b/main.c     2014-07-16 12:53:54.455872459 +0200
@@ -111,6 +111,7 @@
 #if EVENTFD
                   " EVENTFD"
 #endif
+
 #if SELFPIPE
                   " SELFPIPE"
 #endif
@@ -140,6 +141,23 @@
                   argv0);
 }

+#if EVENTFD
+#if defined(__UCLIBC__)
+
+int
+eventfd_read(int fd, eventfd_t* value)
+{
+       return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
+}
+
+int
+eventfd_write(int fd, eventfd_t value)
+{
+       return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
+}
+#endif
+#endif
+
 static void license(void) {
        printf(TITLE "\n\n"
                   "This program is free software: you can redistribute it and/or modify\n"
--- a/squeezelite.h     2014-07-15 12:24:38.190723717 +0200
+++ b/squeezelite.h      2014-07-16 12:52:43.575578071 +0200
@@ -226,6 +226,16 @@
 typedef int32_t   s32_t;
 typedef int64_t   s64_t;

+#if EVENTFD
+#if defined(__UCLIBC__)
+__BEGIN_DECLS
+typedef uint64_t eventfd_t;
+extern int eventfd_read (int __fd, eventfd_t *__value);
+extern int eventfd_write (int __fd, eventfd_t __value);
+__END_DECLS
+#endif
+#endif
+
 #define mutex_type pthread_mutex_t
 #define mutex_create(m) pthread_mutex_init(&m, NULL)
 #define mutex_create_p(m) pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); pthread_mutex_init(&m, &attr); pthread_mutexattr_destroy(&attr)

If anyone could submit this package to the git rep it would be great!

Thanks for the update, joky!  Will come in handy, although first I need to deal with my library dependencies, having trouble with mpg123.

sydorgeck wrote:

Ready to use OpenWRT feed with squeezelite and LuCI application to configure it

Many thanks for that, sydorgeck!  I for one will definitely find it useful.

The discussion might have continued from here.