Asterisk Compile on Alpine

When I attempt to compile Asterisk 18.3.0 on latest Alpine, I get this error:

[pjproject] Compiling lib libpj-x86_64-unknown-linux-gnu.a
make[2]: *** [Makefile:149: /root/asterisk-18.3.0/third-party/pjproject/source/pjlib/lib/libpj-x86_64-unknown-linux-gnu.a] Error 2
make[1]: *** [Makefile:20: pjproject] Error 2
make: *** [Makefile:388: third-party] Error 2

I found some same threads in the forum but didn’t have any solution. Any idea?

Maybe try the latest pjproject on github. The one included with Asterisk 18 is over 1 year old. PJproject have made some improvements and it works great with Asterisk 17, 18, and Git-master. Use ‘./configure --without-pjproject-bundled …’

@cable thanks. I tried to use last pjsip version and that issue has been solved.

But now I get this error:

In file included from /asterisk-18.3.0/include/asterisk.h:23,
from chan_audiosocket.c:33:
/asterisk-18.3.0/include/asterisk/astmm.h:158:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘->’ token
158 | Do_not_use_calloc__use_ast_calloc->fail(a, b)

If you’re using the non-bundled PJproject try this:

sudo su
cd /usr/src/pjproject (or wherever it is located)
make clean
make distclean
./configure --prefix=/usr --enable-shared --enable-ext-sound --disable-opencore-amr --disable-pjsua2 CFLAGS="-O2 -DNDEBUG"
make -s dep
make -s 2>/dev/null
make install
ldconfig

Then retry ‘make install’ in the /usr/src/asterisk-18.3.0 directory

Thanks but it seems the issue is related to “asterisk.h” with musl c lib in Alpine.
I added the “sched.h” in the asterisk.h and the issue changed to this:

ast_expr2.y:277:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘__P’
277 | static int chk_div __P((FP___TYPE, FP___TYPE));

So, no one has compiled Asterisk on Alpine before??

Hope this helps others after me:

https://git.alpinelinux.org/aports/tree/main/asterisk