Cross compile of chan_quectel failed because of C compiler

Hello everyone,

I recently wanted to build an Asterisk based VoIP GSM gateway using the Banana Pi R64 open source router and the Quectel EC25 modem. I built my own OpenWRT image and configured the modem so I am able to send and receive calls and messages through a terminal (e.g. minicom). I can also use Asterisk to create SIP phones and call other SIP phones with them. Now i needed to integrate the modem directly into Asterisk.

I saw an Asterisk channel driver on GitHub (https://github.com/t4rd15/asterisk-chan-quectel) for the EC25 which is a fork of the channel driver for Huaweii based USB modems.

I wanted to cross compile the channel driver for OpenWRT which I saw the creator did for the MIPS architecture but I have not been able to do it for a few days now. I followed the OpenWRT Cross Compile tutorial and I used this command to start cross compilation with autotools:

./configure --with-astversion=18.5.1 --build=x86_64-pc-linux-gnu --host=aarch64-openwrt-linux

The output was:

checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-openwrt-linux-gnu
checking target system type... aarch64-openwrt-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-openwrt-linux-strip... aarch64-openwrt-linux-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for aarch64-openwrt-linux-gcc... aarch64-openwrt-linux-gcc
checking whether the C compiler works... no
configure: error: in `/home/matej/toolchain/asterisk-chan-quectel':
configure: error: C compiler cannot create executables
See `config.log' for more details

The config.log contained:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by chan_quectel configure 1.1, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure --with-astversion=18.5.1 --build=x86_64-pc-linux-gnu --host=aarch64-openwrt-linux

## --------- ##
## Platform. ##
## --------- ##

hostname = ubuntu
uname -m = x86_64
uname -r = 5.11.0-27-generic
uname -s = Linux
uname -v = #29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/matej/.local/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /home/matej/toolchain/bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2334: checking build system type
configure:2348: result: x86_64-pc-linux-gnu
configure:2368: checking host system type
configure:2381: result: aarch64-openwrt-linux-gnu
configure:2401: checking target system type
configure:2414: result: aarch64-openwrt-linux-gnu
configure:2456: checking for a BSD-compatible install
configure:2524: result: /usr/bin/install -c
configure:2535: checking whether build environment is sane
configure:2590: result: yes
configure:2647: checking for aarch64-openwrt-linux-strip
configure:2663: found /home/matej/toolchain/bin/aarch64-openwrt-linux-strip
configure:2674: result: aarch64-openwrt-linux-strip
configure:2739: checking for a thread-safe mkdir -p
configure:2778: result: /usr/bin/mkdir -p
configure:2785: checking for gawk
configure:2801: found /usr/bin/gawk
configure:2812: result: gawk
configure:2823: checking whether make sets $(MAKE)
configure:2845: result: yes
configure:2874: checking whether make supports nested variables
configure:2891: result: yes
configure:3102: checking for aarch64-openwrt-linux-gcc
configure:3118: found /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc
configure:3129: result: aarch64-openwrt-linux-gcc
configure:3204: checking for C compiler version
configure:3213: aarch64-openwrt-linux-gcc --version >&5
/home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/../../host/lib/ld-linux-x86-64.so.2: No such file or directory
configure:3224: $? = 127
configure:3213: aarch64-openwrt-linux-gcc -v >&5
/home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/../../host/lib/ld-linux-x86-64.so.2: No such file or directory
configure:3224: $? = 127
configure:3213: aarch64-openwrt-linux-gcc -V >&5
/home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/../../host/lib/ld-linux-x86-64.so.2: No such file or directory
configure:3224: $? = 127
configure:3213: aarch64-openwrt-linux-gcc -qversion >&5
/home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/../../host/lib/ld-linux-x86-64.so.2: No such file or directory
configure:3224: $? = 127
configure:3244: checking whether the C compiler works
configure:3266: aarch64-openwrt-linux-gcc   -D_GNU_SOURCE  conftest.c  >&5
/home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/../../host/lib/ld-linux-x86-64.so.2: No such file or directory
configure:3270: $? = 127
configure:3308: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "chan_quectel"
| #define PACKAGE_TARNAME "chan_quectel"
| #define PACKAGE_VERSION "1.1"
| #define PACKAGE_STRING "chan_quectel 1.1"
| #define PACKAGE_BUGREPORT "https://github.com/bg111/asterisk-chan-quectel/issues"
| #define PACKAGE_URL "https://github.com/bg111/asterisk-chan-quectel/"
| #define PACKAGE "chan_quectel"
| #define VERSION "1.1"
| #define ASTERISK_VERSION_NUM 180501
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3313: error: in `/home/matej/toolchain/asterisk-chan-quectel':
configure:3315: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-pc-linux-gnu
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=x86_64-pc-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=aarch64-openwrt-linux
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=aarch64-openwrt-linux-gnu
ac_cv_path_install='/usr/bin/install -c'
ac_cv_path_mkdir=/usr/bin/mkdir
ac_cv_prog_AWK=gawk
ac_cv_prog_CC=aarch64-openwrt-linux-gcc
ac_cv_prog_STRIP=aarch64-openwrt-linux-strip
ac_cv_prog_make_make_set=yes
ac_cv_target=aarch64-openwrt-linux-gnu
am_cv_make_support_nested_variables=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

ACLOCAL='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing aclocal-1.16'
AC_CFLAGS=''
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE=''
AMTAR='$${TAR-tar}'
AM_BACKSLASH='\'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
AM_DEFAULT_VERBOSITY='1'
AM_V='$(V)'
AUTOCONF='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing autoconf'
AUTOHEADER='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing autoheader'
AUTOMAKE='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing automake-1.16'
AWK='gawk'
CC='aarch64-openwrt-linux-gcc'
CCDEPMODE=''
CFLAGS=''
CPP=''
CPPFLAGS=' -D_GNU_SOURCE'
CYGPATH_W='echo'
DEFS=''
DEPDIR=''
DESTDIR=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
GREP=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
LDFLAGS=''
LIBOBJS=''
LIBS=''
LTLIBOBJS=''
MAKEINFO='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing makeinfo'
MKDIR_P='/usr/bin/mkdir -p'
OBJEXT=''
PACKAGE='chan_quectel'
PACKAGE_BUGREPORT='https://github.com/bg111/asterisk-chan-quectel/issues'
PACKAGE_NAME='chan_quectel'
PACKAGE_REVISION='43gh=47cg'
PACKAGE_STRING='chan_quectel 1.1'
PACKAGE_TARNAME='chan_quectel'
PACKAGE_URL='https://github.com/bg111/asterisk-chan-quectel/'
PACKAGE_VERSION='1.1'
PATH_SEPARATOR=':'
RM=''
SET_MAKE=''
SHELL='/bin/bash'
SOLINK=''
STRIP='aarch64-openwrt-linux-strip'
TARGET=''
VERSION='1.1'
ac_ct_CC=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__include=''
am__isrc=''
am__leading_dot='.'
am__nodep=''
am__quote=''
am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
bindir='${exec_prefix}/bin'
build='x86_64-pc-linux-gnu'
build_alias='x86_64-pc-linux-gnu'
build_cpu='x86_64'
build_os='linux-gnu'
build_vendor='pc'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host='aarch64-openwrt-linux-gnu'
host_alias='aarch64-openwrt-linux'
host_cpu='aarch64'
host_os='linux-gnu'
host_vendor='openwrt'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh='${SHELL} /home/matej/toolchain/asterisk-chan-quectel/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdir_p='$(MKDIR_P)'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target='aarch64-openwrt-linux-gnu'
target_alias=''
target_cpu='aarch64'
target_os='linux-gnu'
target_vendor='openwrt'

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "chan_quectel"
#define PACKAGE_TARNAME "chan_quectel"
#define PACKAGE_VERSION "1.1"
#define PACKAGE_STRING "chan_quectel 1.1"
#define PACKAGE_BUGREPORT "https://github.com/bg111/asterisk-chan-quectel/issues"
#define PACKAGE_URL "https://github.com/bg111/asterisk-chan-quectel/"
#define PACKAGE "chan_quectel"
#define VERSION "1.1"
#define ASTERISK_VERSION_NUM 180501

configure: exit 77

If anyone can help I'd be really thankful. This is my first time doing a larger project on Linux based systems.

Try installing "ccache" in host machine