Unable to cross compile siproxd with OpenWrt toolchain (pthread not found)

I'm unable to cross compile siproxd for openwrt (stuck at the configure part). I am building within the openwrt build system as described in https://openwrt.org/docs/guide-developer/crosscompile

The configure command I used was the last line:

checking for closedir... no
checking for opendir... no
checking for readdir... no
checking for strlcat... no
checking for strlcpy... no
checking using system provided libltdl... no, using included libltdl
*** WARNING: using convenience libltdl!
checking whether lt_preloaded_symbols is declared... no
checking build documentation... yes
checking for docbook2pdf... no
checking for docbook2html... no
checking link statically against libosip2... no
checking building with DMALLOC support... no
checking target platform... Linux
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... no
checking whether pthreads work with -pthreads... no
checking whether pthreads work with -mthreads... no
checking for the pthreads library -lpthread... no
checking whether pthreads work with --thread-safe... no
checking whether pthreads work with -mt... no
*** ERROR: pthreads is required!
root@b12a52ab1898:/siproxd# ls $STAGING_DIR/lib/libpthread*
/home/openwrt/staging_dir/toolchain-mips_24kc_gcc-10.3.0_musl/lib/libpthread.a
root@b12a52ab1898:/siproxd# ls $STAGING_DIR/include/pthread*
/home/openwrt/staging_dir/toolchain-mips_24kc_gcc-10.3.0_musl/include/pthread.h
root@b12a52ab1898:/siproxd# CFLAGS="-I${STAGING_DIR}/include -I/usr/include -lpthread" LDFLAGS="-L${STAGING_DIR}/lib" LIBS="-lpthread" ./configure --build=mips-unknown-linux-gnu --host=mips-openwrt-linux-musl

Does anyone know why it keeps complaining about pthread even when it's there?

Hi there,

siproxd is already built for OpenWrt automatically. You can just install the package(s).

opkg list|grep siproxd
siproxd - 0.8.3-1 - Siproxd is a proxy/masquerading daemon for the SIP protocol. Refer to https://openwrt.org/docs/guide-user/services/voip/siproxd for configuration details and examples.
siproxd-mod-blacklist - 0.8.3-1 - siproxd blacklist plugin
siproxd-mod-codecfilter - 0.8.3-1 - siproxd codecfilter plugin
siproxd-mod-defaulttarget - 0.8.3-1 - siproxd defaulttarget plugin
siproxd-mod-demo - 0.8.3-1 - siproxd demo plugin
siproxd-mod-fix-DTAG - 0.8.3-1 - siproxd fix_DTAG plugin
siproxd-mod-fix-bogus-via - 0.8.3-1 - siproxd fix_bogus_via plugin
siproxd-mod-fix-fbox-anoncall - 0.8.3-1 - siproxd fix_fbox_anoncall plugin
siproxd-mod-logcall - 0.8.3-1 - siproxd logcall plugin
siproxd-mod-prefix - 0.8.3-1 - siproxd prefix plugin
siproxd-mod-regex - 0.8.3-1 - siproxd regex plugin
siproxd-mod-shortdial - 0.8.3-1 - siproxd shortdial plugin
siproxd-mod-siptrunk - 0.8.3-1 - siproxd siptrunk plugin
siproxd-mod-stats - 0.8.3-1 - siproxd stats plugin
siproxd-mod-stripheader - 0.8.3-1 - siproxd stripheader plugin
siproxd-mod-stun - 0.8.3-1 - siproxd stun plugin

There's also an article on the wiki: Link

Or you can build the package yourself in OpenWrt's buildroot like this, after selecting the packages in menuconfig:

make package/siproxd/{clean,compile} V=s

Kind regards,
Seb

1 Like

I'm aware it exists as a prebuilt package, but I'm trying to create my own plugin in siproxd so I need to be able to build it for the target also to test it on the device.

Maybe I'll take a look at the openwrt buildroot makefiles and try to make sense of it. Thanks.

OK. siproxd should install headers and such into the buildroot staging dir. So maybe your plugin can go into its own Makefile. If the plugin source is public let me know, then I'd give it a try.

1 Like

I haven't written any code yet. Just trying to get a hang of the dev environment first.

My approach is to modify an existing plugin in siproxd source itself (perhaps plugin_shortdial.c) and then try to compile siproxd as whole instead of making a different repo for my plugin with its own Makefile etc. (for the sake of simplicity for now)

I followed https://openwrt.org/docs/guide-developer/single.package and was able to compile siproxd.

The sources and the headers I would need were found at /build_dir/target-mips_24kc_musl/siproxd-0.8.3/src

Are you calling ./configure from the build system, or manually? The build system sets up the build environment (which includes the fakeroot path to $(STAGING_DIR))

Does the package you're hijacking as a base have +libpthread as a DEPENDS?

You might also need TARGET_LDFLAGS += -lpthread in the Makefile, but I would look at the DEPENDS first.

Edit: After changing the Makefile depends, make sure you RERUN make menuconfig, or it will NOT update the pre-reqs in .config

2 Likes

I was calling ./configure manually after exporting PATH and STAGING_DIR as mentioned in crosscompiling docs.

Yes, the ./package/feeds/telephony/siproxd/Makefile does have "+libpthread" as DEPENDS.

I'll guess I'll have to stick to the build system instructions and will use this package source from openwrt feed instead.

There are a LOT of things that are set by the build system, including CONFIGURE_VARS and CONFIGURE_ARGS that are called at the invoke.

Check out the ./include directory for the default defines for things like that.

OpenWrt is designed to have the build system do the building, and manually doing it just won't work - Especially if you're cross-compiling.

You can always manually trigger the package build, but that still uses the build system (aka make package/feeds/packages/siproxd/{clean,configure,compile} or whatever package you are trying to build out

2 Likes