yaroslavche / phptdlib

PHP Extension for tdlib/td written with PHP-CPP
https://yaroslavche.github.io/phptdlib/
MIT License
103 stars 26 forks source link

TDApi and TDLib not visible on PHP #70

Closed wagncarv closed 4 years ago

wagncarv commented 4 years ago

I tried to use phptdlib, but the classes in TDLib and TDApi are not visible to use. Error: Fatal error: Uncaught Error: Class 'TDApi\LogConfiguration' not found in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php:13 Stack trace: #0 {main} thrown in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php on line 13

Fatal error: Uncaught Error: Class 'TDLib\JsonClient' not found in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php:15 Stack trace: #0 {main} thrown in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php on line 15

yaroslavche commented 4 years ago

Are you sure, that you have installed extension? What output you see for following:

$ php -m | grep tdlib
$ php -r "echo (function_exists('td_json_client_create') ? 'ok' : 'failed') . PHP_EOL;"
wagncarv commented 4 years ago

i get the following message: $ php -m | grep tdlib $ php -r "echo (function_exists('td_json_client_create') ? 'ok' : 'failed') . PHP_EOL;" failed

Em qua., 22 de jul. de 2020 às 13:44, Yaroslav notifications@github.com escreveu:

Are you sure, that you have installed extension? What output you see for following:

$ php -m | grep tdlib $ php -r "echo (function_exists('td_json_client_create') ? 'ok' : 'failed') . PHP_EOL;"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yaroslavche/phptdlib/issues/70#issuecomment-662562697, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADVAEXRETUQLU3HADAH222LR44JPDANCNFSM4PEW3SKA .

wagncarv commented 4 years ago

The whole error message:

$ cmake .. -- Could NOT find ccache (this is NOT an error) -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR) -- Found ZLIB: /usr/include /usr/lib/libz.dylib -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR) CMake Warning at modules/td/CMakeLists.txt:279 (message): Not found OpenSSL: skip TDLib, tdactor, tdnet, tddb

-- Using the single-header code from /Applications/Ampps/www/phptdlib/modules/json/single_include/ -- Configuring done CMake Error at CMakeLists.txt:230 (add_executable): Target "tester" links to target "Td::TdJsonStatic" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:230 (add_executable): Target "tester" links to target "Td::TdStatic" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:183 (add_library): Target "tdlib" links to target "Td::TdJsonStatic" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:183 (add_library): Target "tdlib" links to target "Td::TdStatic" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

-- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.

yaroslavche commented 4 years ago

Please install OpenSSL first, then follow installation instructions

wagncarv commented 4 years ago

openssl installed:

**-- Found OpenSSL: /usr/local/Cellar/openssl/1.0.2t/include /usr/lib/libssl.dylib;/usr/lib/libcrypto.dylib**
-- Found ZLIB: /usr/include /usr/lib/libz.dylib
-- Found Readline: /usr/local/opt/readline/include /usr/local/opt/readline/lib/libreadline.dylib
-- Using the single-header code from /Applications/Ampps/www/phptdlib/modules/json/single_include/
-- Configuring done
-- Generating done
-- Build files have been written to: /Applications/Ampps/www/phptdlib/build
Scanning dependencies of target tdlib
CMake Error: Directory Information file not found
[ 14%] Building CXX object CMakeFiles/tdlib.dir/tdlib.cpp.o
/Applications/Ampps/www/phptdlib/tdlib.cpp:5:10: fatal error: 
      'td/telegram/tdjson_export.h' file not found
#include <td/telegram/tdjson_export.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/tdlib.dir/tdlib.cpp.o] Error 1
make[1]: *** [CMakeFiles/tdlib.dir/all] Error 2
make: *** [all] Error 2
yaroslavche commented 4 years ago

Seems that this is not whole output, and I can't say why this happens. Maybe missed something again. Please check also building with shared libs, video instruction and closed issues (might find something useful). Also you can try install on docker And I can't say anything about building on macOS.

wagncarv commented 4 years ago

I really don't know what's going on, even following all the steps on the video and documentation. The files TdConfig.cmake and td-config.cmake just not generate.

pwd

/phptdlib/build

cmake -D USE_SHARED_TD:BOOL=ON -D USE_SHARED_JSON:BOOL=ON -D USE_SHARED_PHPCPP:BOOL=ON ..

-- The CXX compiler identification is GNU 8.3.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:111 (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.6) 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 "/phptdlib/build/CMakeFiles/CMakeOutput.log".

pwd

/phptdlib/build

cmake ..

CMake Error at CMakeLists.txt:111 (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.6) 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 "/phptdlib/build/CMakeFiles/CMakeOutput.log".

yaroslavche commented 4 years ago

If you want use shared libs, then you firstly should install them. Run scripts/install.sh first, before cmake.

$ git clone https://github.com/yaroslavche/phptdlib.git && cd phptdlib
$ CONFIG=gcc CC=gcc CXX=g++ ./scripts/install.sh
$ mkdir build && cd build
$ cmake -D USE_SHARED_TD:BOOL=ON -D USE_SHARED_JSON:BOOL=ON -D USE_SHARED_PHPCPP:BOOL=ON ..
$ make
$ sudo make install

Please read docs carefully.

wagncarv commented 4 years ago

The whole process, step by step, was followed, same result, same error. I tried everything, but nothing seems to make it work, i really don't know. git clone --recurse-submodules https://github.com/yaroslavche/phptdlib.git Cloning into 'phptdlib'... remote: Enumerating objects: 191, done. remote: Counting objects: 100% (191/191), done. remote: Compressing objects: 100% (143/143), done. remote: Total 1816 (delta 114), reused 100 (delta 46), pack-reused 1625 Receiving objects: 100% (1816/1816), 8.99 MiB | 1.82 MiB/s, done. Resolving deltas: 100% (595/595), done. Submodule 'modules/json' (git://github.com/nlohmann/json.git) registered for path 'modules/json' Submodule 'modules/td' (git://github.com/tdlib/td.git) registered for path 'modules/td' Cloning into '/Applications/Ampps/www/phptdlib/modules/json'... remote: Enumerating objects: 1420, done.
remote: Counting objects: 100% (1420/1420), done.
remote: Compressing objects: 100% (327/327), done.
remote: Total 59358 (delta 1064), reused 1226 (delta 970), pack-reused 57938
Receiving objects: 100% (59358/59358), 200.68 MiB | 2.46 MiB/s, done. Resolving deltas: 100% (47499/47499), done. Cloning into '/Applications/Ampps/www/phptdlib/modules/td'... remote: Enumerating objects: 2496, done.
remote: Counting objects: 100% (2496/2496), done.
remote: Compressing objects: 100% (976/976), done.
remote: Total 40747 (delta 1457), reused 2160 (delta 1353), pack-reused 38251
Receiving objects: 100% (40747/40747), 15.14 MiB | 1.40 MiB/s, done. Resolving deltas: 100% (28785/28785), done. Submodule path 'modules/json': checked out 'fbec662afab55019654e471b65a846a47a696722' Submodule path 'modules/td': checked out 'f45d80fe16f99d112d545b7cd74ce46342fe3437' iMac-de-Luciano-4:www lucianopezzin$ cd phptdlib iMac-de-Luciano-4:phptdlib lucianopezzin$ CONFIG=gcc CC=gcc CXX=g++ ./scripts/install.sh ./scripts/install.sh: line 39: declare: -A: invalid option declare: usage: declare [-afFirtx] [-p] [name[=value] ...] Build 0 in /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Cloning into '.'... remote: Enumerating objects: 2496, done. remote: Counting objects: 100% (2496/2496), done. remote: Compressing objects: 100% (976/976), done. remote: Total 40747 (delta 1457), reused 2160 (delta 1353), pack-reused 38251 Receiving objects: 100% (40747/40747), 15.14 MiB | 3.09 MiB/s, done. Resolving deltas: 100% (28785/28785), done. Build 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Install 0 from /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. /Applications/Ampps/www/phptdlib/scripts/functions.sh: line 57: cd: /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026: No such file or directory Install 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. iMac-de-Luciano-4:phptdlib lucianopezzin$ mkdir build && cd build iMac-de-Luciano-4:build lucianopezzin$ cmake -D USE_SHARED_TD:BOOL=ON -D USE_SHARED_JSON:BOOL=ON -D USE_SHARED_PHPCPP:BOOL=ON .. -- The CXX compiler identification is AppleClang 10.0.0.10001044 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:111 (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.

iMac-de-Luciano-4:phptdlib lucianopezzin$ CONFIG=gcc CC=gcc CXX=g++ ./scripts/install.sh ./scripts/install.sh: line 39: declare: -A: invalid option declare: usage: declare [-afFirtx] [-p] [name[=value] ...] Build 0 in /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Cloning into '.'... remote: Enumerating objects: 2496, done. remote: Counting objects: 100% (2496/2496), done. remote: Compressing objects: 100% (976/976), done. remote: Total 40747 (delta 1457), reused 2160 (delta 1353), pack-reused 38251 Receiving objects: 100% (40747/40747), 15.14 MiB | 1.69 MiB/s, done. Resolving deltas: 100% (28785/28785), done. Build 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Install 0 from /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. /Applications/Ampps/www/phptdlib/scripts/functions.sh: line 57: cd: /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026: No such file or directory Install 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026.

wagncarv commented 4 years ago

Following "installation with shared libraries", step by step strictly, but the same error, doesn't work for me. $ git clone https://github.com/yaroslavche/phptdlib.git Cloning into 'phptdlib'... remote: Enumerating objects: 191, done. remote: Counting objects: 100% (191/191), done. remote: Compressing objects: 100% (143/143), done. remote: Total 1816 (delta 114), reused 100 (delta 46), pack-reused 1625 Receiving objects: 100% (1816/1816), 8.99 MiB | 2.03 MiB/s, done. Resolving deltas: 100% (595/595), done. iMac-de-Luciano-4:www lucianopezzin$ cd phptdlib iMac-de-Luciano-4:phptdlib lucianopezzin$ CONFIG=gcc CC=gcc CXX=g++ ./scripts/install.sh ./scripts/install.sh: line 39: declare: -A: invalid option declare: usage: declare [-afFirtx] [-p] [name[=value] ...] Build 0 in /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Cloning into '.'... remote: Enumerating objects: 2496, done. remote: Counting objects: 100% (2496/2496), done. remote: Compressing objects: 100% (976/976), done. remote: Total 40747 (delta 1457), reused 2160 (delta 1353), pack-reused 38251 Receiving objects: 100% (40747/40747), 15.14 MiB | 3.39 MiB/s, done. Resolving deltas: 100% (28785/28785), done. Build 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. Install 0 from /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. /Applications/Ampps/www/phptdlib/scripts/functions.sh: line 57: cd: /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026: No such file or directory Install 0 failed (1). Remove cache /Applications/Ampps/www/phptdlib/cached_builds/Darwin/gcc/0/41cac3edba3ffe6c014f951fc753e4982b859026. iMac-de-Luciano-4:phptdlib lucianopezzin$ mkdir build && cd build iMac-de-Luciano-4:build lucianopezzin$ cmake -D USE_SHARED_TD:BOOL=ON -D USE_SHARED_JSON:BOOL=ON -D USE_SHARED_PHPCPP:BOOL=ON .. -- The CXX compiler identification is AppleClang 10.0.0.10001044 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:111 (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.6) 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 "/Applications/Ampps/www/phptdlib/build/CMakeFiles/CMakeOutput.log".

yaroslavche commented 4 years ago

./scripts/install.sh: line 39: declare: -A: invalid option Build 0 failed (1).

Read carefully. I can't say anything about macOS. Please use docker or find how to build tdlib/td. This isn't this package issue. When you'll have installed tdlib/td, then extension should build.

And I've checked what wrong. Seems in macOS not possible to declare assoc array in shell script. Anyway you should install tdlib/td. Only then you can use extension, which using tdlib/td

mensenvau commented 4 years ago

php -i | grep tdlib

how to set this command to work

yaroslavche commented 4 years ago

how to set this command to work

In console. You should call PHP interpreter. Also you can check in modules list: php -m | grep tdlib image