Table of Contents
1) Symptoms of the problem
After selecting the necessary modules in the make menuselect
(including the chan_iax2
driver – which is selected for installation by default) and executing the make
command, an error related to the operation of the gcc compiler will appear.
[CC] chan_iax2.c → chan_iax2.o
chan_iax2.c:418:64: error: expected ‘;’, ‘,’ or ‘)’ before ‘buf’
static char *auth_method_names(int authmethods, char *restrict buf)
static char *auth_method_names(int authmethods, char *restrict buf)
^
chan_iax2.c: In function ‘socket_process_helper’:
chan_iax2.c:11533:8: warning: implicit declaration of function ‘auth_method_names’ [-Wimplicit-function-declaration]
ast_verb(3, “Accepting AUTHENTICATED call from %s:\n”
^
chan_iax2.c:11533:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 8 has type ‘int’ [-Wformat=]
make[1]: *** [chan_iax2.o] Error 1
make: *** [channels] Error 2
2) Cause of the problem
Patch 59bc6ce, which fixed authentication debugging issues for chan_iax2
, used the restrict keyword in the definition of the new auth_method_names
function, but this keyword is not supported in gcc versions <= 4.9. This causes compilation failure on distros such as CentOS7 where only gcc version 4.8 is available.
For example, in the latest version of CentOS 7 it looks like this:
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
As you can see, we are using gcc version 4.8.5.
The fix was released in March 2024, as indicated in the official pages like: ChangeLog. It says:
- #586: [bug]: The “restrict” keyword used in chan_iax2.c isn’t supported in older gcc versions.
3) Solution
The best solution will be to simply install a newer version of Asterisk (released after March 2024) or install it on a newer, and therefore more secure, operating system. If for some reason this is not possible, you will find a solution below.
It often turns out that the default Asterisk compilation and installation parameters contain a lot of components, drivers and audio files that we do not need. It is worth manually reviewing the compiler options and removing those components that we will not use. If in this case the chan_iax2
driver will not be needed for anything, simply uncheck it before executing the make
command.
make menuselect
However, if we need chan_iax2
, we need to execute the configure command again, this time with the -std=gnu99
flag. The gcc compiler for CentOS 7 uses the-std=gnu90
flag by default.
./configure --with-jansson-bundled CFLAGS=-std=gnu99
make
command again, which this time completes without errors.
make
So we can continue configuring our system.
But let’s be honest… wouldn’t it be better to think about updating the software?
If you would like to monitor everything, that is happening on your PBX, try our proprietary VoiperoManager software.
Setup takes only a few minutes and the system is completely FREE.
Read, what our VoiperoManager system can do in terms of live monitoring and reporting of VoIP systems based on Asterisk.