Closed SamHz closed 4 years ago
检查下/usr/include/opencc这个路径是否存在,不存在的话,configure的时候使用--with-opencc=指定相应的路径
cd /usr/include/opencc
/usr/include/opencc# ls
opencc.h opencc_types.h openccxx.h
刚查看了一下目录存在的,目录权限如下
ls -ld
drwxr-xr-x 2 root root 4096 Dec 24 14:28 .
我本地ubuntu18.04 PHP7.3安装是正常使用的
安装opencc > 1.0的版本,ubuntu18.04 的libopencc-dev 的版本是1.0.4-5的
README里写了需要1.0.1版本以上的opencc
@pkujhd 如何重装opencc?
https://github.com/BYVoid/OpenCC 里有说明可以自己编译安装,或者你下个deb自己手动安装
/usr/lib/php/20160303$ ls
build gettext.so opcache.so shmop.so wddx.so
calendar.so iconv.so **opencc.so** simplexml.so xmlreader.so
ctype.so json.so pdo_dblib.so soap.so xml.so
curl.so ldap.so pdo_mysql.so sockets.so xmlwriter.so
dom.so mbstring.so pdo_odbc.so swoole.so xsl.so
exif.so mcrypt.so pdo.so sysvmsg.so zip.so
fileinfo.so mysqli.so phar.so sysvsem.so
ftp.so mysqlnd.so posix.so sysvshm.so
gd.so odbc.so readline.so tokenizer.so
抱歉,问题比较多,PHP已经存在这个了,可以没有opencc4php.so这要怎么做 Thank you for helping to make PHP better. Makefile:134: recipe for target 'test' failed make: *** [test] Error 1 make test报了个错,我用非root也是报错的
/bin/bash /home/cust/opencc4php/libtool --mode=install cp ./opencc.la /home/cust/opencc4php/modules
libtool: install: cp ./.libs/opencc.so /home/cust/opencc4php/modules/opencc.so
cp: cannot create regular file '/home/cust/opencc4php/modules/opencc.so': Permission denied
Makefile:196: recipe for target '/home/cust/opencc4php/modules/opencc.la' failed
make: *** [/home/cust/opencc4php/modules/opencc.la] Error 1
Warning: opencc_convert() expects parameter 2 to be resource, boolean given in /var/www/html/gts-eip/public/test.php on line 4
Warning: opencc_close() expects parameter 1 to be resource, boolean given in /var/www/html/gts-eip/public/test.php on line 6
opencc4php.so 这个是你编译出来的, 你要放在/user下面,用sudo make install,否则就放在一个你指定的目录,在php.ini里配置一下
sudo make install
[sudo] password for gts:
/bin/bash /home/gts/opencc4php/libtool --mode=install cp ./opencc.la /home/gts/opencc4php/modules
libtool: install: cp ./.libs/opencc.so /home/gts/opencc4php/modules/opencc.so
libtool: install: cp ./.libs/opencc.lai /home/gts/opencc4php/modules/opencc.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /home/gts/opencc4php/modules
----------------------------------------------------------------------
Libraries have been installed in:
/home/gts/opencc4php/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/lib/php/20160303/
opencc --version
Open Chinese Convert (OpenCC) Command Line Tool
Version: 1.0.4
opencc已经安装了1.0.4的版本 好像编译出来的是opencc.so已经引用了,但是还是用不了提示 Warning: opencc_convert() expects parameter 2 to be resource, boolean given in /var/www/html/gts-eip/public/test.php on line 4
Warning: opencc_close() expects parameter 1 to be resource, boolean given in /var/www/html/gts-eip/public/test.php on line 6 最少PHP是能解释opencc_open这个函数,但是因为$od = opencc_open("s2twp.json"); 我猜想是s2twp.json找不到造成$od 为空,这个文件我/usr/share/opencc/下是有的,我还给了全部读写权限,但还是不行,是否有全路径要写或者要在那里配置的呢?请指点一二 代码:
<?php
$od = opencc_open("/usr/share/opencc/s2twp.json"); //传入配置文件名
var_dump($od);
$text = opencc_convert($_GET['name'], $od);
echo $text;
opencc_close($od);
打印结果$od : boolean(false)
类似的错误,请问这个怎么处理? ubuntu16.04 和 php7.1.3
Originally posted by @SamHz in https://github.com/nauxliu/opencc4php/issues/35#issuecomment-568673534