Infactum / tg2sip

Telegram <-> SIP voice gateway
GNU General Public License v2.0
272 stars 104 forks source link

Instructions to build in Raspberry Pi Bullseye 64-bit [aarch64] #69

Open mghadam opened 1 year ago

mghadam commented 1 year ago

Notes when compiling on Raspberry Pi 11 (bullseye) 64-bit-

  1. @IchthysMaranathy has mentioned two patches for https://github.com/Infactum/tg2sip/issues/49#issue-925872339 . The first patch for <emmintrin.h> was not required for pjsip v2.12.1. However, tg2sip is not compatible with this version of pjsip and returns https://github.com/Infactum/tg2sip/issues/35#issue-666114258 regarding ep.codecEnum2(). Therefore it is needed to use pjsip v2.9 and apply the patch. The second patch for endianess is required for both pjsip v2.9 and v2.12.1

  2. Debian bullseye includes spdlog v1.8.1 while tg2sip requires v0.17. Therefore a manual compilation is needed for spdlog.

  3. The latest version of tdlib v1.8.7 return errors error: ‘td_api::authorizationStateWaitEncryptionKey’ has not been declared when compiling. However, v1.8.0 release works fine.

Here is the gist I used to compile tg2sip on RPi 64-bit bullseye. The compiled binaries are attached.

tg2sip_aarch64.zip

# Freepbx / Asterisk installation https://remosim.com/software-installation/
# Enable slin48 (for L16@48000) and opus (for OPUS@48000) in Freepbx -> Settings -> Asterisk Sip Settings

mkdir ~/src

apt-get install gperf -y

# sse2neon https://github.com/Infactum/tg2sip/issues/49
cd ~/src
wget https://github.com/DLTcollab/sse2neon/archive/refs/tags/v1.5.1.tar.gz
tar -zxvf v1.5.1.tar.gz
cd sse2neon*
sudo cp sse2neon.h /usr/local/include

# PJSip v2.9
cd ~/src
wget https://github.com/pjsip/pjproject/archive/refs/tags/2.9.tar.gz
tar -zxvf 2.9.tar.gz
cd pjproject*
grep -rl emmintrin.h . | xargs sed -i -e "s,emmintrin.h,sse2neon.h,g" # https://github.com/Infactum/tg2sip/issues/49#issue-925872339
./configure
make
sudo make install

# spdlog 0.17 https://github.com/gabime/spdlog/releases
cd ~/src
wget https://github.com/gabime/spdlog/archive/refs/tags/v0.17.0.tar.gz
tar -zxvf v0.17.0.tar.gz
cd spdlog*
mkdir build
cd build
cmake ../
make
sudo make install

# tdlib https://github.com/tdlib/td  https://github.com/tdlib/td/issues/1627#issuecomment-885993462
cd ~/src
wget https://github.com/tdlib/td/archive/refs/tags/v1.8.0.tar.gz
tar -zxvf v1.8.0.tar.gz
cd td-*
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..
sudo cmake --build . --target install

# tg2sip
cd ~/src
wget https://github.com/Infactum/tg2sip/archive/refs/tags/v1.3.0.tar.gz
tar -zxf v1.3.0.tar.gz
cd tg2sip*
# apply patches https://github.com/Infactum/tg2sip/issues/49 
sed -i CMakeLists.txt -e "s,1.7.10,1.8.0,g"
vi /usr/local/include/pj/config.h # https://github.com/Infactum/tg2sip/issues/49#issue-925872339
===========
replace the following lines:
#else
#   error "Please specify target machine."
#endif
with
#else
#   define PJ_HAS_PENTIUM   0
#   define PJ_IS_LITTLE_ENDIAN  1
#   define PJ_IS_BIG_ENDIAN 0
#   define PJ_M_ARM7        1
#   define PJ_M_NAME        "armv7"
#endif
===========
vi tg2sip/utils.cpp # https://github.com/Infactum/tg2sip/issues/50#issuecomment-1247856447
===========
add the following line in the includes section:
#include <string>
===========

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../ 
cmake --build .
oibafrc commented 1 year ago

An image for raspberry 4 with the system all working would be very useful.

oibafrc commented 1 year ago

I did all the compilation above, however, when I run ./tg2sip, I get the following error:

oot@raspberrypi:/usr/src/tg2sip-1.3.0/build# ./tg2sip [14:16:07.655][t:21847][p:21847][pjsip][info] pjsua version 2.9 for Linux-5.15.84/aarch64/glibc-2.31 initialized [14:16:07.657][t:21847][p:21847][pjsip][error] Invalid local URI: Invalid URI (PJSIP_EINVALIDURI) [status=171039] [14:16:07.657][t:21847][p:21847][pjsip][error] Error adding account: Invalid URI (PJSIP_EINVALIDURI) [status=171039] [14:16:07.657][t:21847][p:21847][pjsip][error] pjsua_acc_add(&pj_acc_cfg, make_default, &id) error: Invalid URI (PJSIP_EINVALIDURI) (status=171039) [../src/pjsua2/account.cpp:963] Abortado