Infactum / tg2sip

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

tg2sip on FreeBSD #37

Open ogogon opened 3 years ago

ogogon commented 3 years ago

Can tg2cip, without major modifications, be compiled on the FreeBSD platform?

Infactum commented 3 years ago

Tg2sip itself don't use any platform specific code if I remember correctly. Anyway I can't say wether it or its dependencies are tested on freeBSD.

ogogon commented 3 years ago
  1. I've never worked with spdlog, but something is wrong with it. Cmake doesn't want to work with her.
  2. What is Td?
root@ogogon:/usr/local/src/tg2sip # uname -a
FreeBSD devel.ogogon.org 11.4-RELEASE-p2 FreeBSD 11.4-RELEASE-p2 #0: Tue Aug  4 19:21:02 UTC 2020     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
root@ogogon:/usr/local/src/tg2sip # pkg info cmake spdlog
cmake-3.18.2
spdlog-1.8.0_1
root@ogogon:/usr/local/src/tg2sip # cmake CMakeLists.txt
CMake Warning at libtgvoip/CMakeLists.txt:7 (find_package):
  Could not find a configuration file for package "spdlog" that is compatible
  with requested version "0.17".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/spdlog/spdlogConfig.cmake, version: 1.8.0

-- Could NOT find spdlog
CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "FindTd.cmake" in CMAKE_MODULE_PATH this project has asked
  CMake to find a package configuration file provided by "Td", but CMake did
  not find one.

  Could not find a package configuration file provided by "Td" (requested
  version 1.6.0) with any of the following names:

    TdConfig.cmake
    td-config.cmake

  Add the installation prefix of "Td" to CMAKE_PREFIX_PATH or set "Td_DIR" to
  a directory containing one of the above files.  If "Td" provides a separate
  development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!
See also "/usr/local/src/tg2sip/CMakeFiles/CMakeOutput.log".
See also "/usr/local/src/tg2sip/CMakeFiles/CMakeError.log".
root@ogogon:/usr/local/src/tg2sip #

Am I doing something wrong?

Infactum commented 3 years ago

You are trying to compile against newer version of spdlog (1.8.0) than requested one (0.17). Td is telegram database library. Btw it has build instructions for freeBSD here. Most probably you'll need to build all dependencies by yourself. See buildenv and CI scripts as examples and do same this with freeBSD specific.

ogogon commented 3 years ago

You are trying to compile against newer version of spdlog (1.8.0) than requested one (0.17).

As far as I understand, version 0.17 is no longer supported. Where can I get it? Standard methods for installing programs in FreeBSD offer only version 1.8.0. Thus, I must not act very correctly. Remove the correctly installed version 1.8.0, and then compile and install the obsolete version without using the software packages control mechanism.

Sorry if my question is tactless, but you have no plans to rewrite your product using the current version spdlog?

Infactum commented 3 years ago

It doesn't matter what version is used by freeBSD package manager. Build dependencies but don't install them system-wide. Later they will be statically linked to tg2sip binary so your system won't be affected in any way.

I have no plans to update any dependencies to newer versions until current one are working stable and no new features are needed.

ogogon commented 3 years ago

For the Td library, you have set version 1.6.0 find_package(Td 1.6.0 REQUIRED) Now, the current version is 1.6.8.

They will be compatible, or only need to use 1.6.0?

Infactum commented 3 years ago

If Td uses semver, then 1.6.0 and 1.6.8 should have same API.

ogogon commented 3 years ago

Please comment on the following situation. When compiling, I get diagnostics:

[ 97%] Building CXX object CMakeFiles/tg2sip.dir/tg2sip/sip.cpp.o
/usr/bin/c++ -DPJ_AUTOCONF -DTGVOIP_USE_DESKTOP_DSP -DTGVOIP_USE_SOFTWARE_AUDIO -DTGVOIP_USE_SPDLOG -I/usr/local/src/spdlog-0.17.0/package/include -I/usr/local/src/td-1.6.0 -I/usr/local/include -I/usr/local/src/tg2sip -I/usr/local/include/opus -I/usr/local/src/tg2sip/include -isystem /usr/local/src/td-1.6.0/tdlib/include -O3 -DNDEBUG -std=gnu++17 -o CMakeFiles/tg2sip.dir/tg2sip/sip.cpp.o -c /usr/local/src/tg2sip/tg2sip/sip.cpp
/usr/local/src/tg2sip/tg2sip/sip.cpp:198:27: error: member reference type 'const pj::CodecInfo' is not a pointer; did you mean to use '.'?
        ep.codecSetPriority(value->codecId, (pj_uint8_t) (value->codecId == codecId ? 255 : 0));
                            ~~~~~^~
                                 .
/usr/local/src/tg2sip/tg2sip/sip.cpp:198:57: error: member reference type 'const pj::CodecInfo' is not a pointer; did you mean to use '.'?
        ep.codecSetPriority(value->codecId, (pj_uint8_t) (value->codecId == codecId ? 255 : 0));
                                                          ~~~~~^~
                                                               .
2 errors generated.
*** Error code 1

Stop.
make[2]: stopped in /usr/local/src/tg2sip/build
*** Error code 1

Stop.
make[1]: stopped in /usr/local/src/tg2sip/build
*** Error code 1

Stop.

If I make corrections suggested by the compiler, then everything goes without errors. Here is my version of the CLang and SIP-stack:

ogogon@ogogon:/usr/local/src/tg2sip/build# clang --version
FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd11.4
Thread model: posix
InstalledDir: /usr/bin
ogogon@ogogon:/usr/local/src/tg2sip/build# pkg info pjsip
pjsip-2.10_1

What does this mean? There was a bug in the program, but everyone was compiling it? Or have I mistakenly followed the compiler's recommendation and introduced an error into the code?

Infactum commented 3 years ago

Well I'm gonna say it once again: please check existing CI build scripts. Current tg2sip version is build against pjproject 2.9. Your package version is 2.10. There is even issue about this here. Also pjproject must be properly configured before compilation with config_site.h. Thats the second reason why you should build it yourself.