首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
PHP-X 测试提示libphpx.so: cannot open shared object
先总结下 编译都成功了,扩展cpp_ext.so也加到php.ini中了就是不能正常运行, 提示:'/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 当添加了libphpx.so到php.ini再运行提示: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 现在不理解libphpx.so的具体作用,github、wik.swoole.com上也没有明确如何使用这个,只是提到了添加编译后的扩展到php.ini中,帮忙解决下,多谢了!环境Ubtuntu16.04 php7以下是安装步骤。 1.Build libphpx.so root@caojiabin:/home/PHP-X# cmake . -DPHP_CONFIG_DIR=/usr/local/software/php/v71/bin PHP_INCLUDE_DIR: /usr/local/software/php/v71/include/php -- Configuring done -- Generating done -- Build files have been written to: /home/PHP-X root@caojiabin:/home/PHP-X# make -j 4 [100%] Built target phpx root@caojiabin:/home/PHP-X# sudo make install [100%] Built target phpx Install the project... -- Install configuration: "Debug" Are you run command using root user? -- Up-to-date: /usr/local/lib/libphpx.so -- Up-to-date: /usr/local/include/phpx.h -- Up-to-date: /usr/local/include/phpx_embed.h root@caojiabin:/home/PHP-X# 2.编译cpp_ext 先修改Makefile指定php7 root@caojiabin:/home/PHP-X/examples/cpp_ext# cat Makefile PHP_INCLUDE = `/usr/local/software/php/v71/bin/php-config --includes` PHP_LIBS = `/usr/local/software/php/v71/bin/php-config --libs` PHP_LDFLAGS = `/usr/local/software/php/v71/bin/php-config --ldflags` PHP_INCLUDE_DIR = `/usr/local/software/php/v71/bin/php-config --include-dir` PHP_EXTENSION_DIR = `/usr/local/software/php/v71/bin/php-config --extension-dir` cpp_ext.so: extension.cpp c -DHAVE_CONFIG_H -g -o cpp_ext.so -O0 -fPIC -shared extension.cpp -std=c 11 -lphpx ${PHP_INCLUDE} -I${PHP_INCLUDE_DIR} test.so: test.cpp c -DHAVE_CONFIG_H -g -o test.so -O0 -fPIC -shared test.cpp -std=c 11 -lphpx ${PHP_INCLUDE} -I${PHP_INCLUDE_DIR}\ -I${PHP_INCLUDE_DIR}/ext/swoole/include -I${PHP_INCLUDE_DIR}/ext/swoole install: cpp_ext.so cp cpp_ext.so ${PHP_EXTENSION_DIR}/ clean: rm *.so 安装 root@caojiabin:/home/PHP-X/examples/cpp_ext# make install cp cpp_ext.so `/usr/local/software/php/v71/bin/php-config --extension-dir`/ root@caojiabin:/home/PHP-X/examples/cpp_ext# 3.在php.ini中增加 extension = cpp_ext.so 4.运行测试例子 root@caojiabin:/home/PHP-X/examples/cpp_ext# /usr/local/software/php/v71/bin/php dump.php PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 5.当我试着添加libphpx.so到php.ini中再次运行提示如下 root@caojiabin:/home/PHP-X/examples/cpp_ext# /usr/local/software/php/v71/bin/php dump.php PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2
发布于6年前 · 2 次浏览 · 来自
提问
p
phpup
先总结下 编译都成功了,扩展cpp_ext.so也加到php.ini中了就是不能正常运行, 提示:'/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 当添加了libphpx.so到php.ini再运行提示: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 现在不理解libphpx.so的具体作用,github、wik.swoole.com上也没有明确如何使用这个,只是提到了添加编译后的扩展到php.ini中,帮忙解决下,多谢了!环境Ubtuntu16.04 php7以下是安装步骤。 1.Build libphpx.so root@caojiabin:/home/PHP-X# cmake . -DPHP_CONFIG_DIR=/usr/local/software/php/v71/bin PHP_INCLUDE_DIR: /usr/local/software/php/v71/include/php -- Configuring done -- Generating done -- Build files have been written to: /home/PHP-X root@caojiabin:/home/PHP-X# make -j 4 [100%] Built target phpx root@caojiabin:/home/PHP-X# sudo make install [100%] Built target phpx Install the project... -- Install configuration: "Debug" Are you run command using root user? -- Up-to-date: /usr/local/lib/libphpx.so -- Up-to-date: /usr/local/include/phpx.h -- Up-to-date: /usr/local/include/phpx_embed.h root@caojiabin:/home/PHP-X# 2.编译cpp_ext 先修改Makefile指定php7 root@caojiabin:/home/PHP-X/examples/cpp_ext# cat Makefile PHP_INCLUDE = `/usr/local/software/php/v71/bin/php-config --includes` PHP_LIBS = `/usr/local/software/php/v71/bin/php-config --libs` PHP_LDFLAGS = `/usr/local/software/php/v71/bin/php-config --ldflags` PHP_INCLUDE_DIR = `/usr/local/software/php/v71/bin/php-config --include-dir` PHP_EXTENSION_DIR = `/usr/local/software/php/v71/bin/php-config --extension-dir` cpp_ext.so: extension.cpp c -DHAVE_CONFIG_H -g -o cpp_ext.so -O0 -fPIC -shared extension.cpp -std=c 11 -lphpx ${PHP_INCLUDE} -I${PHP_INCLUDE_DIR} test.so: test.cpp c -DHAVE_CONFIG_H -g -o test.so -O0 -fPIC -shared test.cpp -std=c 11 -lphpx ${PHP_INCLUDE} -I${PHP_INCLUDE_DIR}\ -I${PHP_INCLUDE_DIR}/ext/swoole/include -I${PHP_INCLUDE_DIR}/ext/swoole install: cpp_ext.so cp cpp_ext.so ${PHP_EXTENSION_DIR}/ clean: rm *.so 安装 root@caojiabin:/home/PHP-X/examples/cpp_ext# make install cp cpp_ext.so `/usr/local/software/php/v71/bin/php-config --extension-dir`/ root@caojiabin:/home/PHP-X/examples/cpp_ext# 3.在php.ini中增加 extension = cpp_ext.so 4.运行测试例子 root@caojiabin:/home/PHP-X/examples/cpp_ext# /usr/local/software/php/v71/bin/php dump.php PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 5.当我试着添加libphpx.so到php.ini中再次运行提示如下 root@caojiabin:/home/PHP-X/examples/cpp_ext# /usr/local/software/php/v71/bin/php dump.php PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpx.so' in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/software/php/v71/lib/php/extensions/no-debug-non-zts-20160303/cpp_ext.so' - libphpx.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2 Fatal error: Uncaught ReflectionException: Class CppInterface does not exist in /home/PHP-X/examples/cpp_ext/dump.php:2 Stack trace: #0 [internal function]: ReflectionClass->__construct('CppInterface') #1 /home/PHP-X/examples/cpp_ext/dump.php(2): ReflectionClass::export('CppInterface') #2 {main} thrown in /home/PHP-X/examples/cpp_ext/dump.php on line 2
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2018-10-31
旋
旋风
libphpx.so不是放在php.ini里。 把libphpx.so所在的目录添加到/etc/ld.so.conf文件里,之后运行ldconfig命令
赞
0
回复
微信公众号
热门内容
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。