Giter Site home page Giter Site logo

Comments (16)

maxvgi avatar maxvgi commented on June 18, 2024 1

Hi, @DavidCima
It seems that there is a bug in CMakeLists.txt

I will try to fix it. For now, please send me output of command php-config --configure-options

I am intrested in --with-config-file-scan-dir= option.

from phptdlib.

maxvgi avatar maxvgi commented on June 18, 2024 1

@DavidCima, did you try to build the project after the latest cc8ebc3 commit?

from phptdlib.

 avatar commented on June 18, 2024 1

Hi @maxvgi @yaroslavche
It seems that after the last "commit" the problem with the command has been solved and it no longer throws the error: "Undefined symbols for architecture x86_64."

make
make

directory tree "build"
build

However now it throws me another error when I run "sudo make install":
sudo_make_install

It occurs to me that maybe it is a problem with the write permissions. I will check and comment on the result. No doubt it seems that we are on the right track.

from phptdlib.

 avatar commented on June 18, 2024 1

Well, I have managed to solve the problems with write permissions in the / usr / lib / php / extensions / no-debug-non-zts-20160303 folder.

It has been really difficult since my system did not allow me to change the read to write permission. In case someone else happens, this is what you need to do:

  • Restart the MAC.
  • During the restart, press CMD + R.
  • When the system options appear, go to "Utilities-> terminal" and type: csrutil disable and then reboot.
  • Now you can modify the permissions.

Once the writing is allowed, I execute "sudo make install" and it compiles well, at least in appearance.

install

tdlib

I modify my "php.ini" file by adding the line extension = tdlib.dylib

php -i | grep tdlib
php ../php_examples/func.php

and then I get this error ...

Mac:build davidgarcia$ php -i | grep tdlib
PWD => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
$_SERVER['PWD'] => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
$_ENV['PWD'] => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
Mac:build davidgarcia$ php ../php_examples/func.php

Fatal error: Uncaught Error: Call to undefined function td_json_client_create() in /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/php_examples/func.php:8
Stack trace:
#0 {main}
  thrown in /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/php_examples/func.php on line 8
Mac:build davidgarcia$ php ../php_examples/func.php

Fatal error: Uncaught Error: Call to undefined function td_json_client_create() in /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/php_examples/func.php:8
Stack trace:
#0 {main}
  thrown in /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/php_examples/func.php on line 8

from phptdlib.

maxvgi avatar maxvgi commented on June 18, 2024 1

@DavidCima and one more thing to try.

Find the following fragment in CMakeLists.txt

if(APPLE)
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
endif()

and replace it with

if(APPLE)
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")

    set(BUNDLE_EXTENSION ".so")
    add_library(${EXT_NAME} MODULE ${SOURCE_FILES})
    set_target_properties(${EXT_NAME} PROPERTIES BUNDLE TRUE)
else()
    add_library(${EXT_NAME} SHARED ${SOURCE_FILES})
endif()

I have no Mac so I cannot try it by myself currently.

from phptdlib.

 avatar commented on June 18, 2024

Mac:/ davidgarcia$ php-config --configure-options

--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --sysconfdir=/private/etc --with-libdir=lib --enable-cli --with-iconv=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-config-file-path=/etc --with-libxml-dir=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-openssl=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl --with-kerberos=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-zlib=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-bcmath --with-bz2=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-calendar --disable-cgi --with-curl=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-dba --with-ndbm=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-exif --enable-fpm --enable-ftp --with-gd --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --enable-gd-native-ttf --with-icu-dir=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-ldap=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-ldap-sasl=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-libedit=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-mbstring --enable-mbregex --with-mysqli=mysqlnd --with-pcre-regex=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --without-pcre-jit --with-pdo-pgsql=/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain/usr/local/bin --with-pgsql=/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain/local/bin --without-pear --with-pear=no --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/mysql/mysql.sock --disable-phpdbg --with-readline=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-shmop --with-snmp=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --enable-wddx --with-xmlrpc --with-iconv-dir=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-xsl=/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr --with-apxs2=/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain/usr/local/bin/apxs --enable-zip YACC=/BuildRoot/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison

from phptdlib.

maxvgi avatar maxvgi commented on June 18, 2024

In your configuration you have to add the extension to your system manually.

You have file tdlib.so in your build directory. Copy it to your php extensions directory. You can get the path to extension directory using the command:

php-config --extension-dir

Then add the following text to your php.ini file:

extension=tdlib.so

I will patch CMake script soon. It will give these instructions to users with such configuration.

from phptdlib.

 avatar commented on June 18, 2024

I have not managed to find the file "tdlib.so" in the compilation of my project.

phptdlib
1

PHP-CPP
2

That's why I decided to reinstall everything seeing that the "CMake" file had been fixed.
Now I get another error when I run the "make" command:

[100%] Linking CXX shared library tdlib.dylib
Undefined symbols for architecture x86_64:
  "BaseJsonClient::__toString()", referenced from:
      Php::Class<BaseJsonClient>::callToString(Php::Base*) const in tdlib.cpp.o
      Php::Class<JsonClient>::callToString(Php::Base*) const in tdlib.cpp.o
  "BaseJsonClient::__callStatic(char const*, Php::Parameters&)", referenced from:
      std::__1::enable_if<HasCallStatic<BaseJsonClient>::value, Php::Value>::type Php::Class<BaseJsonClient>::maybeCallStatic<BaseJsonClient>(char const*, Php::Parameters&) in tdlib.cpp.o
      std::__1::enable_if<HasCallStatic<JsonClient>::value, Php::Value>::type Php::Class<JsonClient>::maybeCallStatic<JsonClient>(char const*, Php::Parameters&) in tdlib.cpp.o
  "BaseJsonClient::__get(Php::Value const&)", referenced from:
      Php::Class<BaseJsonClient>::callGet(Php::Base*, Php::Value const&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callGet(Php::Base*, Php::Value const&) const in tdlib.cpp.o
  "BaseJsonClient::__set(Php::Value const&, Php::Value const&)", referenced from:
      Php::Class<BaseJsonClient>::callSet(Php::Base*, Php::Value const&, Php::Value const&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callSet(Php::Base*, Php::Value const&, Php::Value const&) const in tdlib.cpp.o
  "BaseJsonClient::__call(char const*, Php::Parameters&)", referenced from:
      Php::Class<BaseJsonClient>::callCall(Php::Base*, char const*, Php::Parameters&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callCall(Php::Base*, char const*, Php::Parameters&) const in tdlib.cpp.o
  "BaseJsonClient::__isset(Php::Value const&)", referenced from:
      Php::Class<BaseJsonClient>::callIsset(Php::Base*, Php::Value const&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callIsset(Php::Base*, Php::Value const&) const in tdlib.cpp.o
  "BaseJsonClient::__unset(Php::Value const&)", referenced from:
      Php::Class<BaseJsonClient>::callUnset(Php::Base*, Php::Value const&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callUnset(Php::Base*, Php::Value const&) const in tdlib.cpp.o
  "BaseJsonClient::__invoke(Php::Parameters&)", referenced from:
      Php::Class<BaseJsonClient>::callInvoke(Php::Base*, Php::Parameters&) const in tdlib.cpp.o
      Php::Class<JsonClient>::callInvoke(Php::Base*, Php::Parameters&) const in tdlib.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [tdlib.dylib] Error 1
make[1]: *** [CMakeFiles/tdlib.dir/all] Error 2
make: *** [all] Error 2

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

@DavidCima, i think you will not find the file until the extension was builded =)
The result of the build (tdlib.so) will need to be copied by yourself into the extensions folder php-config --extension-dir and add an entry to the php.ini. As @maxvgi mention above.
Now you still have issue with make. Hope this helps: SO:Xcode build failure โ€œUndefined symbols for architecture x86_64โ€.

from phptdlib.

 avatar commented on June 18, 2024

Thanks for the help. I suppose then that the error I have now is due to "XCode". I will explore the solutions to see if I can compile. A greeting.

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

@DavidCima As I can understand - your php -i | grep tdlib command output is nothing?
For example you must receive something like this:

yaroslav@linux-lvf5:~> php -i | grep tdlib
/etc/php7/conf.d/tdlib.ini,
tdlib

Otherwise extension wasn't loaded and sure that PHP don't know anything about that function td_json_client_create. It's hard to say why it's happens on Mac. I suggest try to find info how to install php dylib extension on Mac.

It would be great a little bit more info.

  1. Whole php.ini file (use pastebin, f.e.)
cd /usr/lib/php/extensions/non-debug-non-zts-20160303
php -r 'dl("tdlib.dylib")'
  1. Maybe on Mac extension ini file placed in specific directory that includes automatically (in build directory you have tdlib.ini, check it)
  2. Maybe in tdlib.ini must be extension=tdlib (without file extension)
  3. Maybe it must be tdlib.so, IDK =)

from phptdlib.

 avatar commented on June 18, 2024

@DavidCima As I can understand - your php -i | grep tdlib command output is nothing?
For example you must receive something like this:

yaroslav@linux-lvf5:~> php -i | grep tdlib
/etc/php7/conf.d/tdlib.ini,
tdlib

Otherwise extension wasn't loaded and sure that PHP don't know anything about that function td_json_client_create. It's hard to say why it's happens on Mac. I suggest try to find info how to install php dylib extension on Mac.

It would be great a little bit more info.

  1. Whole php.ini file (use pastebin, f.e.)
cd /usr/lib/php/extensions/non-debug-non-zts-20160303
php -r 'dl("tdlib.dylib")'
  1. Maybe on Mac extension ini file placed in specific directory that includes automatically (in build directory you have tdlib.ini, check it)
  2. Maybe in tdlib.ini must be extension=tdlib (without file extension)
  3. Maybe it must be tdlib.so, IDK =)

@yaroslavche Sorry forget to put the output of "php -i | grep tdlib":

Mac:build davidgarcia$ php -i | grep tdlib
PWD => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
$_SERVER['PWD'] => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
$_ENV['PWD'] => /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/build
  1. This is my "php.ini" file: https://pastebin.com/P6y2S9jk .

  2. This is the exit that returns me:

Mac:no-debug-non-zts-20160303 davidgarcia$  php -r 'dl("tdlib.dylib")'
Parse error: syntax error, unexpected end of file in Command line code on line 1

3,4 & 5. I have tried all the extensions (.so, .dylib, .ini and without extension), but none works.

from phptdlib.

 avatar commented on June 18, 2024

if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") set(BUNDLE_EXTENSION ".so") add_library(${EXT_NAME} MODULE ${SOURCE_FILES}) set_target_properties(${EXT_NAME} PROPERTIES BUNDLE TRUE) else() add_library(${EXT_NAME} SHARED ${SOURCE_FILES}) endif()

After modifying the "CMakeLists" file that is in the "build" folder of the "phptdlib" project, I get this:

Mac:build davidgarcia$ cmake ..
-- Could NOT find ccache
-- Found OpenSSL: /usr/local/opt/openssl/include /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib
-- Found ZLIB: /usr/include /usr/lib/libz.dylib
-- Performing Test GNU_READLINE_FOUND
-- Performing Test GNU_READLINE_FOUND - Failed
-- Could NOT find Readline (missing: READLINE_INCLUDE_DIR READLINE_LIBRARY) 
-- Could NOT find Readline
-- Using the single-header code from /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/modules/json/single_include/
CMake Error at CMakeLists.txt:183 (add_library):
  add_library cannot create target "tdlib" because another target with the
  same name already exists.  The existing target is a module library created
  in source directory "/Applications/MAMP/htdocs/TelegramRecorder/phptdlib".
  See documentation for policy CMP0002 for more details.

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/"

ls -la /Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/

also interesting this:

php-config --extension-dir
ls -la $(php-config --extension-dir)

and I think that's be enough to copy tdlib.dylib into that dir and write tdlib.dylib in php.ini.

about output with PWD. PWD - current working directory, so if you run php -i | grep tdlib in dir that not contain tdlib in name - than I think you see no mention. That's mean extension not loaded.

and in php.ini
must be extension=tdlib.dylib in this case. Or without file extension - just extension=tdlib. Or .so when use CMakeLists.txt fix mentioned by @maxvgi . Just remove another line add_library(${EXT_NAME} SHARED ${SOURCE_FILES}).

How it must works: in ini file you tell to PHP that you have extension with name tdlib. PHP search that file in php-config --extension-dir and load if exists. Than you can check, if module is loaded. Also can load by yourself with dl function that not working for you, because i forget about semicolon in the end: dl("name.ext");. Many ways to check. You need be sure, that tdlib extension is loaded.
Or, f.e., another check: php -r 'echo class_exists("TDLib\\JsonClient") ? "exists" . PHP_EOL : "not exists" . PHP_EOL;'

from phptdlib.

 avatar commented on June 18, 2024

It's funny, I've noticed that if I execute:
"php-config --extension-dir" returns the route:
"/ usr / lib / php / extensions / no-debug-non-zts-20160303"
Instead, as you say, in the configuration of "php.ini" the path established to load the modules is:
/Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/

In any case what I do is copy the file "tdlib.dylib" in both places and then add it to my php.ini as we said: "extension = tdlib.dylib".
The flaw is that it does not seem to recognize the file and does not load it (maybe it's because of the extension ".dylib" instead of ".so"?).

To verify it I am placed in the directory and I do:
"php -r 'echo class_exists (" TDLib \ JsonClient ")?" exists ". PHP_EOL:" not exists ". PHP_EOL;' "He returns me" Does not exist ".
To make sure I do php -m and check that the extension does not load despite being in the directory.

Mac:no-debug-non-zts-20170718 davidgarcia$ php -m

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imap
intl
json
ldap
libxml
mbstring
memcached
mysqli
mysqlnd
OAuth
openssl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]
Xdebug

Anyway, despite having a Mac my knowledge is quite limited. I believe that in the end I will mount a virtual machine with Linux and try again.
Anyway, I would like to thank you for your help.

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

maybe it's because of the extension ".dylib" instead of ".so"?

maybe. For build .so you need use this CMakeLists.txt
After this you must reproduce the same steps as with dylib. Don't forget about extension=tdlib.so in php.ini

from phptdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.