如何修复 asterisk 1.8.18+ 编译错误?

How to fix asterisk 1.8.18+ compile error?

我正在编译 Asterisk 1.8.32.3(错误从 1.8.18 开始仍然存在),最后我得到这个错误:

root@ubuntu:/usr/src/asterisk-1.8.32.3# make
CC="cc" CXX="" LD="" AR="" RANLIB="" CFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" makeopts
make[1]: Entering directory '/usr/src/asterisk-1.8.32.3/menuselect'
make[1]: 'makeopts' is up to date.
make[1]: Leaving directory '/usr/src/asterisk-1.8.32.3/menuselect'
   [CC] tcptls.c -> tcptls.o
*tcptls.c: In function ‘tcptls_stream_close’:
tcptls.c:401:20: error: dereferencing pointer to incomplete type
    if (!stream->ssl->server) {*
                    ^
tcptls.c:403:5: warning: ‘ERR_remove_state’ is deprecated (declared at /usr/include/openssl/err.h:261) [-Wdeprecated-declarations]
     ERR_remove_state(0);
     ^
tcptls.c: In function ‘__ssl_setup’:
tcptls.c:768:4: warning: implicit declaration of function ‘SSLv2_client_method’ [-Wimplicit-function-declaration]
    cfg->ssl_ctx = SSL_CTX_new(SSLv2_client_method());
    ^
tcptls.c:768:4: warning: passing argument 1 of ‘SSL_CTX_new’ makes pointer from integer without a cast [enabled by default]
In file included from /usr/src/asterisk-1.8.32.3/include/asterisk/tcptls.h:59:0,
                 from tcptls.c:44:
/usr/include/openssl/ssl.h:1503:17: note: expected ‘const struct SSL_METHOD *’ but argument is of type ‘int’
 __owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
                 ^
tcptls.c:773:4: warning: implicit declaration of function ‘SSLv3_client_method’ [-Wimplicit-function-declaration]
    cfg->ssl_ctx = SSL_CTX_new(SSLv3_client_method());
    ^
tcptls.c:773:4: warning: passing argument 1 of ‘SSL_CTX_new’ makes pointer from integer without a cast [enabled by default]
In file included from /usr/src/asterisk-1.8.32.3/include/asterisk/tcptls.h:59:0,
                 from tcptls.c:44:
/usr/include/openssl/ssl.h:1503:17: note: expected ‘const struct SSL_METHOD *’ but argument is of type ‘int’
 __owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
                 ^
tcptls.c:775:4: warning: ‘TLSv1_client_method’ is deprecated (declared at /usr/include/openssl/ssl.h:1879) [-Wdeprecated-declarations]
    cfg->ssl_ctx = SSL_CTX_new(TLSv1_client_method());
    ^
/usr/src/asterisk-1.8.32.3/Makefile.rules:109: recipe for target 'tcptls.o' failed
make[1]: *** [tcptls.o] Error 1
Makefile:351: recipe for target 'main' failed
make: *** [main] Error 2

最重要的是行:

tcptls.c: In function ‘tcptls_stream_close’:
tcptls.c:401:20: error: dereferencing pointer to incomplete type
    if (!stream->ssl->server) {
                    ^

我正在使用 dahdi 2.11.2 和 g++/gcc 4.8; 在 Ubuntu 16.04

上编译

有人知道如何解决这个问题吗?

P.S。我只需要编译 asterisk 1.8.18+ 并且只需要在 Ubuntu 16.04.

您应该使用较旧的 SSL 版本(这通常也意味着其他 OS)或较新的星号版本。

1.8.x 不再支持。

您可以使用 dahdi 作为一个模块,而不是重新编译整个 Asterisk。

你直接编译dahdi

我在 1.8.32 上做过几次,从来没有重新编译发行版 Asterisk。

我自己找到了解决方案:

要编译安装asterisk,需要gcc/g++ 4.4/4.8。还有 openssl 1.0.2。但是,安装后应该更换新的,否则 mysql 将无法在 asterisk 和 Freeswitch 中工作。

旧的openssl和gcc的旧编译版本也允许执行curl,否则应该替换为shell

用旧的替换新的 openssl:

# will install libssl-dev as a dependency
apt install libmysqlclient-dev

# download required package manually 
apt download libssl1.0.0
apt download libssl1.0-dev
apt download libcurl3
apt download libcurl-openssl1.0-dev

# remove libssl-dev without removing libmysqlclient-dev
dpkg -r --force-depends libssl-dev
dpkg -r --force-depends libcurl4
dpkg -r --force-depends libcurl4-openssl-dev

# install libssl1.0-dev manually
dpkg -i libssl1.0-dev_1.0.2n-1ubuntu5.4_amd64.deb
dpkg -i libcurl3_7.58.0-2ubuntu2_amd64.deb
dpkg -i libcurl-openssl1.0-dev_7.58.0-2ubuntu2_amd64.deb