动态加载 CEF, dynamic load cef

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了动态加载 CEF, dynamic load cef相关的知识,希望对你有一定的参考价值。

参考技术A 最近打算用 CEF 给我们自己的应用做一套插件系统,功能很简单,简单说来就两个:支持自定义 js 接口,支持 html 页面展现。

做的时候遇到了一个问题,就是 CEF 官方示例都是基于 CEF 进程架构,只要主程序一启动,相关进程都要起来。我们的需求是,当前应用程序只有在需要 CEF 的时候再启动。所以,要搞定的是动态加载 CEF,启动相关进程。

总体的实现思路如下:

PHP启动:动态库加载失败(PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php7/lib/php

  今天在linux上面智障一般搞了好久,本来想安装个swoole的,然后用  php -m 的命令想看下安装的PHP扩展库,发现有的扩展库有的可以出来,有的加载失败,

  加载失败的错误类型:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/memcached.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/memcached.so: undefined symbol: zend_new_interned_string in Unknown on line 0

  如下:

[[email protected] /]# php -m
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/memcached.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/memcached.so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/swoole.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/swoole.so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/redis.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/redis.so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/curl.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/fileinfo.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/gd.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/json.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/phar.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/phar.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/zip.so‘ - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bz2
calendar
Core
ctype
date
ereg
exif
filter
ftp
gettext
gmp

 上面的意思是 :找不到扩展库的路径; 这是为什么尼?不是有的扩展库也可以出来吗?

然后我是百度上找各种答案,并不能解决我的问题,最后自己发现问题所在:

因为我并没有为所有的扩展库加了快捷链接,以为在哪里只要用  php -m 的命令就可以查看所有的扩展库。

其实是要:/usr/local/php7/bin/php  -m  这个命令才可以,我的是PHP7.0版本的,其他版本自己换下这个路径就好。

如此,就可以看到所有的扩展库了:

[[email protected] bin]# /usr/local/php7/bin/php -m 
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
swoole
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

[Zend Modules]

以上是关于动态加载 CEF, dynamic load cef的主要内容,如果未能解决你的问题,请参考以下文章

PHP Warning: PHP Startup: Unable to load dynamic library ‘swoole.so‘

跨平台 C++ 动态库插件加载器

自己编写jQuery动态引入js文件插件 (jquery.import.dynamic.script)

gcc dynamic load library

Android 动态加载技术简单易懂的介绍方式

ELF格式解读 Dynamic节