yujirotakahashi / fasttext-php Goto Github PK
View Code? Open in Web Editor NEWPHP bindings for fastText. https://github.com/facebookresearch/fastText
PHP bindings for fastText. https://github.com/facebookresearch/fastText
After installation fasttext and install php module I see error: Warning: PHP Startup: Unable to load dynamic library 'path_to_fasttext/fasttext.so' - libfasttext.so: cannot open shared object file: No such file or directory in Unknown on line 0
I'm not understand what I should to do then solve this problem. Please help me.
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getWordVectors’:
/home/setup/fastText/fastText-php/fasttext.c:257:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int64_t idx=0; idx<ft_vecs->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c:257:2: note: use option -std=c99 or -std=gnu99 to compile your code
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getSubwordVector’:
/home/setup/fastText/fastText-php/fasttext.c:282:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int64_t idx=0; idx<ft_vecs->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getSentenceVectors’:
/home/setup/fastText/fastText-php/fasttext.c:307:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int64_t idx=0; idx<ft_vecs->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getPredict’:
/home/setup/fastText/fastText-php/fasttext.c:339:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int idx=0; idx<ft_vals->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getNN’:
/home/setup/fastText/fastText-php/fasttext.c:371:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int idx=0; idx<ft_vals->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getAnalogies’:
/home/setup/fastText/fastText-php/fasttext.c:403:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int idx=0; idx<ft_vals->size; idx++) {
^
/home/setup/fastText/fastText-php/fasttext.c: In function ‘zim_fasttext_getNgramVectors’:
/home/setup/fastText/fastText-php/fasttext.c:434:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
I've tried to install fastText-php in the official php docker image (php:7.4-rc
). But didn't succeed. Perhaps there is an environment variable missing, where the extensions looks for the shared object?!?
curl
, build-essential
, cmake
via apt-getPHP Warning: PHP Startup: Unable to load dynamic library 'fasttext.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so (libfasttext.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
root@a89af4900f55:~# fdfind libfasttext /
/tmp/fastText-0.2.0/build/libfasttext.a
/tmp/fastText-0.2.0/build/libfasttext.so
/tmp/fastText-0.2.0/build/libfasttext_pic.a
/usr/local/lib/libfasttext.a
/usr/local/lib/libfasttext.so
/usr/local/lib/libfasttext_pic.a
root@a89af4900f55:~# fdfind fasttext.h /
/tmp/fastText-0.2.0/src/fasttext.h
/tmp/fastText-0.2.0/website/static/docs/en/html/classfasttext_1_1FastText.html
/tmp/fastText-0.2.0/website/static/docs/en/html/namespacefasttext.html
/tmp/fastText-php-master/php_fasttext.h
/usr/local/include/fasttext/fasttext.h
root@a89af4900f55:~# fdfind fasttext.so /
/tmp/fastText-php-master/modules/fasttext.so
/usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so
root@a89af4900f55:~# env | sort
GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312
HOME=/root
HOSTNAME=a89af4900f55
OLDPWD=/tmp/fastText-php-master
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c
PHP_ASC_URL=https://downloads.php.net/~derick/php-7.4.0beta1.tar.xz.asc
PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2
PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2
PHP_INI_DIR=/usr/local/etc/php
PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie
PHP_MD5=
PHP_SHA256=399727399ac3c98c981e623ce2f4e55940ee1f99829cfcbca914d878a6910d30
PHP_URL=https://downloads.php.net/~derick/php-7.4.0beta1.tar.xz
PHP_VERSION=7.4.0beta1
PWD=/root
SHLVL=0
TERM=xterm
_=/usr/bin/env
root@a89af4900f55:~# php -i | grep "Scan this dir for"
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
root@a89af4900f55:~# ls -l /usr/local/etc/php/conf.d
total 8
-rw-r--r-- 1 root root 20 Jul 27 01:29 docker-php-ext-sodium.ini
-rw-r--r-- 1 root root 22 Jul 31 08:39 fasttext.ini
root@a89af4900f55:~# cat /usr/local/etc/php/conf.d/fasttext.ini
extension=fasttext.so
root@a89af4900f55:~# php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'fasttext.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so (libfasttext.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20190529/fasttext.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.0beta1 (cli) (built: Jul 27 2019 01:28:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
Dear Takahashi-san,
It seems I've run into a similar issue as Issue #2:
I've installed fasttext 0.1.0 using cmake and it's running fine on the command line, alas after following your instructions for installing the php-bindings I still get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/fasttext.so' - libfasttext.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Uncaught Error: Class 'fastText' not found in /home/aqbanking/fasttext.php:3
Stack trace:
#0 {main}
thrown in /home/aqbanking/fasttext.php on line 3
any ideas?
On line :
$ftext = new fastText();
thrown error :
PHP Fatal error: Uncaught Error: Class 'fastText' not found in ...
Note : no error on extension loading.
Configuration info
I have followed the installation instructions ... but replaced 0.9.1 by 0.9.2. No issue during installation. (ubuntu 18.04 / PHP 7.2)
Added in php.ini :
extension=/home/parallels/fastText-php/modules/fasttext.so
Added in '/etc/environment':
PATH=" (...) :/home/parallels/fastText-php/modules"
Takahashi-san,
fastText was installed without a problem but during make session of fastText-php, I encountered the following error message;
/my-dir/fastText-php/json.hpp:67:10: error: #error "unsupported GCC version - see (URL is omitted)
My GCC version is 4.8.5-36.
What's going on and let me know how to resolve this situation.
Thanks in advance,
Kiyoshi Hirose.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.