RoEdAl / asterisk-chan-quectel

Asterisk channel driver for Quectel and SimCOM modules
GNU General Public License v2.0
18 stars 6 forks source link

Cannot compile on FreePBX 16.0 #15

Closed stich86 closed 2 months ago

stich86 commented 3 months ago

Hi @RoEdAl,

i'm trying to compile this module on FreePBX 16.0 (based con CentOS 7.8), but after install cmake (that is not present on this Linux version), during the build I got this error:

root@freepbx asterisk-chan-quectel]# cmake --build build
[  4%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_parse.c.o
/root/asterisk-chan-quectel/src/at_parse.c: In function ‘at_parse_cops’:
/root/asterisk-chan-quectel/src/at_parse.c:118:5: error: initializer element is not constant
     static const size_t delimiters_no1 = delimiters_no - 1u;
     ^
gmake[2]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/at_parse.c.o] Errore 1
gmake[1]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/all] Errore 2
gmake: *** [all] Errore 2

Any suggestion? Asterisk version is 18.16.0, headers are present. The version from @IchthysMaranatha was working and compiled successfully. Tried also pre-built from your releses, but GLIBC is different.

Thanks in advance!

RoEdAl commented 3 months ago

This may be an old version of GCC (~4.8) which handles const expressions wrongly. Check your GCC version and try to upgrade it if possible. GCC version 10 or above should be fine.

stich86 commented 3 months ago

This may be an old version of GCC (~4.8) which handles const expressions wrongly. Check your GCC version and try to upgrade it if possible. GCC version 10 or above should be fine.

thanks for the link.. i've enable SCL and switch to GCC 11, but still same problem:

[root@freepbx asterisk-chan-quectel]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
[root@freepbx asterisk-chan-quectel]# ./build-chan-quectel.cmake
[  4%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_parse.c.o
[  8%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_response.c.o
[ 12%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/smsdb.c.o
[ 16%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/pcm.c.o
/root/asterisk-chan-quectel/src/smsdb.c: In function ‘init_stmt’:
/root/asterisk-chan-quectel/src/smsdb.c:105:5: warning: implicit declaration of function ‘sqlite3_prepare_v3’ [-Wimplicit-function-declaration]
     if (sqlite3_prepare_v3(smsdb, sql, len, SQLITE_PREPARE_PERSISTENT, stmt, NULL) != SQLITE_OK) {
     ^
/root/asterisk-chan-quectel/src/smsdb.c:105:45: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
     if (sqlite3_prepare_v3(smsdb, sql, len, SQLITE_PREPARE_PERSISTENT, stmt, NULL) != SQLITE_OK) {
                                             ^
/root/asterisk-chan-quectel/src/smsdb.c:105:45: note: each undeclared identifier is reported only once for each function it appears in
gmake[2]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/smsdb.c.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
/root/asterisk-chan-quectel/src/at_parse.c: In function ‘at_parse_cops’:
/root/asterisk-chan-quectel/src/at_parse.c:118:5: error: initializer element is not constant
     static const size_t delimiters_no1 = delimiters_no - 1u;
     ^
/root/asterisk-chan-quectel/src/at_response.c: In function ‘at_response_cusd’:
gmake[2]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/at_parse.c.o] Error 1
/root/asterisk-chan-quectel/src/at_response.c:1919:17: error: initializer element is not constant
                 static const size_t OUT_UCS2_BUF_SIZE = sizeof(uint16_t) * USSD_DEF_LEN;
                 ^
gmake[2]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/at_response.c.o] Error 1
gmake[1]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/all] Error 2
gmake: *** [all] Error 2
CMake Error at build-chan-quectel.cmake:5 (EXECUTE_PROCESS):
  EXECUTE_PROCESS failed command indexes:

    1: "Child return code: 2"
stich86 commented 3 months ago

so i've clean up all stuff, now error is different:

[root@freepbx asterisk-chan-quectel]# ./make-build-dir.cmake
Preset CMake variables:

  CMAKE_C_STANDARD:STRING="99"
  CMAKE_C_STANDARD_REQUIRED:BOOL="TRUE"
  CMAKE_C_VISIBILITY_PRESET:STRING="hidden"
  CMAKE_INSTALL_DEFAULT_COMPONENT_NAME:STRING="chan-quectel"
  CMAKE_INSTALL_PREFIX:PATH="/usr"
  CMAKE_VISIBILITY_INLINES_HIDDEN:BOOL="TRUE"
  CPACK_DEBIAN_PACKAGE_SHLIBDEPS:BOOL="TRUE"
  CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS:STRING="OWNER_READ;OWNER_WRITE;OWNER_EXECUTE;GROUP_READ;GROUP_EXECUTE;WORLD_READ;WORLD_EXECUTE"
  CPACK_PACKAGE_CHECKSUM:STRING="SHA256"
  CPACK_PACKAGE_CONTACT:STRING="roed@onet.eu"
  CPACK_PACKAGE_DIRECTORY:PATH="/root/asterisk-chan-quectel/package"
  CPACK_PACKAGE_VENDOR:STRING="Undefined"
  CPACK_RESOURCE_FILE_LICENSE:FILEPATH="/root/asterisk-chan-quectel/LICENSE.md"
  CPACK_SET_DESTDIR:BOOL="TRUE"
  CPACK_STRIP_FILES:BOOL="TRUE"
  CPACK_THREADS:STRING="0"
  THREADS_PREFER_PTHREAD_FLAG:BOOL="TRUE"

Preset environment variables:

  CMAKE_INSTALL_MODE="COPY"

-- Found clang-format: CLANG_FORMAT_EXE-NOTFOUND
-- Project version: 2023.12.13-3-g9b9f5c
-- Asterisk version: 180000
-- The C compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/rh/devtoolset-10/root/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for asterisk.h
-- Looking for asterisk.h - found
-- Looking for 3 include files stdarg.h, ..., asterisk/frame.h
-- Looking for 3 include files stdarg.h, ..., asterisk/frame.h - found
-- Looking for AST_CONTROL_SRCCHANGE
-- Looking for AST_CONTROL_SRCCHANGE - not found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for memchr
-- Looking for memchr - found
-- Looking for memmove
-- Looking for memmove - found
-- Looking for memset
-- Looking for memset - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for realpath
-- Looking for realpath - found
-- Looking for strtol
-- Looking for strtol - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for memmem
-- Looking for memmem - not found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strncasecmp
-- Looking for strncasecmp - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for termios.h
-- Looking for termios.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found ALSA: /usr/lib64/libasound.so (found version "1.1.8")
-- Found SQLite3: /usr/include (found version "3.7.17")
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
CMake Warning at src/CMakeLists.txt:50 (MESSAGE):
  Cannot create formatting targets - clang-format not found

CMake Warning at CMakeLists.txt:248 (MESSAGE):
  Can not find dpkg in your path, setting CPACK_PACKAGE_ARCHITECTURE to
  amd64.

-- Configuring done (1.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/asterisk-chan-quectel/build
[root@freepbx asterisk-chan-quectel]# ./make-package.cmake
[root@freepbx asterisk-chan-quectel]# ./build-chan-quectel.cmake
[  4%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/app.c.o
[  8%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_parse.c.o
[ 12%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_command.c.o
[ 16%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_queue.c.o
[ 20%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_read.c.o
[ 25%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/at_response.c.o
[ 29%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/chan_quectel.c.o
[ 33%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/channel.c.o
[ 37%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/char_conv.c.o
[ 41%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/cli.c.o
[ 45%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/helpers.c.o
[ 50%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/memmem.c.o
[ 54%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/ringbuffer.c.o
[ 58%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/cpvt.c.o
[ 62%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/dc_config.c.o
[ 66%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/pdu.c.o
[ 70%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/mixbuffer.c.o
[ 75%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/pdiscovery.c.o
[ 79%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/error.c.o
[ 83%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/smsdb.c.o
[ 87%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/monitor_thread.c.o
[ 91%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/tty.c.o
[ 95%] Building C object src/CMakeFiles/asterisk-chan-quectel.dir/pcm.c.o
/root/asterisk-chan-quectel/src/smsdb.c: In function ‘init_stmt’:
/root/asterisk-chan-quectel/src/smsdb.c:105:9: warning: implicit declaration of function ‘sqlite3_prepare_v3’; did you mean ‘sqlite3_prepare_v2’? [-Wimplicit-function-declaration]
  105 |     if (sqlite3_prepare_v3(smsdb, sql, len, SQLITE_PREPARE_PERSISTENT, stmt, NULL) != SQLITE_OK) {
      |         ^~~~~~~~~~~~~~~~~~
      |         sqlite3_prepare_v2
/root/asterisk-chan-quectel/src/smsdb.c:105:45: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
  105 |     if (sqlite3_prepare_v3(smsdb, sql, len, SQLITE_PREPARE_PERSISTENT, stmt, NULL) != SQLITE_OK) {
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/asterisk-chan-quectel/src/smsdb.c:105:45: note: each undeclared identifier is reported only once for each function it appears in
gmake[2]: *** [src/CMakeFiles/asterisk-chan-quectel.dir/build.make:342: src/CMakeFiles/asterisk-chan-quectel.dir/smsdb.c.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/asterisk-chan-quectel.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
CMake Error at build-chan-quectel.cmake:5 (EXECUTE_PROCESS):
  EXECUTE_PROCESS failed command indexes:

    1: "Child return code: 2"

EDIT: looks like sqlite3 into CentOS 7 doesn't have sqlite3_prepare_v3

stich86 commented 3 months ago

ok I was able to compile changing SQLite3 version, but now module doesn't load because asterisk is build against a different SQLite3 version... that's a nightmare

RoEdAl commented 3 months ago

Upgrading SQLite isn't a good idea. Try to compile module using sources from sqlite branch without changing SQLite version.

stich86 commented 3 months ago

Upgrading SQLite isn't a good idea. Try to compile module using sources from sqlite branch without changing SQLite version.

Thx for the hint

Because it's currently a test, I've installed Debian 12 and moved to beta version of FreePBX17. Module seems to work (via UAC), I've a problem on inbound cal (with VoLTE enabled), but looks like that Quectel SIP INVITE is not accepted by my telco :(

I'll test it later with SIMCOM module and other sims

Anyway I'll push some info tomorrow on how to compile on FreePBX16 distro, trying to use sqlite branch

Thx again for you help!

stich86 commented 3 months ago

just an update:

I was able to make it works with Vodafone IT SIM (ho-mobile MVNO) and UAC. Audio is perfect and works on both direction (inbound/outbound). The major issue was related to the fact that Vodafone IT always sends "IMS" APN if nothing is configured, and in this case the module refues to register over VoLTE.

Still no working with WIND IT and their MVNO (Very in my case). I'll test it in the next weeks with TIM IT that the most important for me because i've to use with thieir SIM :)

RoEdAl commented 3 months ago

I've added Dockerfile that demonstrates how to build chan_quectel for CentOS 7.8 via Docker. Maybe you find this useful.

stich86 commented 3 months ago

Wow, this is very useful and avoid and headache on install all stuff on current version. Thanks mate!