PHP5加载|安装外部C动态库

[1] cd php-5.3.9/ext

[2] ./ext_skel --extname=ncdocxml

[3] cd ncdocxml

[4] nano -w config.m4
############
删除 3 个 dnl

dnl PHP_ARG_WITH(my_module, for my_module support,

dnl Make sure that the comment is aligned:

dnl [ --with-my_module Include my_module support])


或者删除 下边这3个 dnl

dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,

dnl Make sure that the comment is aligned:

dnl [ --enable-my_module Enable my_module support])
############

[5] nano -w ncdocxml.c
############
/*+----------------------------------------------------------------------+| PHP Version 5                                                        |+----------------------------------------------------------------------+| Copyright (c) 1997-2012 The PHP Group                                |+----------------------------------------------------------------------+| This source file is subject to version 3.01 of the PHP license,      || that is bundled with this package in the file LICENSE, and is        || available through the world-wide-web at the following url:           || http://www.php.net/license/3_01.txt                                  || If you did not receive a copy of the PHP license and are unable to   || obtain it through the world-wide-web, please send a note to          || license@php.net so we can mail you a copy immediately.               |+----------------------------------------------------------------------+| Author:                                                              |+----------------------------------------------------------------------+
*//* $Id: header 321634 2012-01-01 13:15:04Z felipe $ */#ifdef HAVE_CONFIG_H
#include "config.h"
#endif#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_ncdocxml.h"
#include "/usr/local/libncdocxml.h"
/*extern int NcXmlDocGetClass(char * infile); */
/* If you declare any globals in php_ncdocxml.h uncomment this:
ZEND_DECLARE_MODULE_GLOBALS(ncdocxml)
*//* True global resources - no need for thread safety here */
static int le_ncdocxml;/* {{{ ncdocxml_functions[]** Every user visible function must have an entry in ncdocxml_functions[].*/
const zend_function_entry ncdocxml_functions[] = {PHP_FE(confirm_ncdocxml_compiled,       NULL)           /* For testing, remove later. */PHP_FE(ncdocxml, NULL)PHP_FE_END      /* Must be the last line in ncdocxml_functions[] */
};
/* }}} *//* {{{ ncdocxml_module_entry*/
zend_module_entry ncdocxml_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901STANDARD_MODULE_HEADER,
#endif"ncdocxml",ncdocxml_functions,PHP_MINIT(ncdocxml),PHP_MSHUTDOWN(ncdocxml),PHP_RINIT(ncdocxml),                    /* Replace with NULL if there's nothing to do at request start */PHP_RSHUTDOWN(ncdocxml),                /* Replace with NULL if there's nothing to do at request end */PHP_MINFO(ncdocxml),
#if ZEND_MODULE_API_NO >= 20010901"0.1", /* Replace with version number for your extension */
#endifSTANDARD_MODULE_PROPERTIES
};
/* }}} */#ifdef COMPILE_DL_NCDOCXML
ZEND_GET_MODULE(ncdocxml)
#endif/* {{{ PHP_INI*/
/* Remove comments and fill if you need to have entries in php.ini
PHP_INI_BEGIN()STD_PHP_INI_ENTRY("ncdocxml.global_value",      "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_ncdocxml_globals, ncdocxml_globals)STD_PHP_INI_ENTRY("ncdocxml.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_ncdocxml_globals, ncdocxml_globals)
PHP_INI_END()
*/
/* }}} *//* {{{ php_ncdocxml_init_globals*/
/* Uncomment this function if you have INI entries
static void php_ncdocxml_init_globals(zend_ncdocxml_globals *ncdocxml_globals)
{ncdocxml_globals->global_value = 0;ncdocxml_globals->global_string = NULL;
}
*/
/* }}} *//* {{{ PHP_MINIT_FUNCTION*/
PHP_MINIT_FUNCTION(ncdocxml)
{/* If you have INI entries, uncomment these linesREGISTER_INI_ENTRIES();*/return SUCCESS;
}
/* }}} *//* {{{ PHP_MSHUTDOWN_FUNCTION*/
PHP_MSHUTDOWN_FUNCTION(ncdocxml)
{/* uncomment this line if you have INI entriesUNREGISTER_INI_ENTRIES();*/return SUCCESS;
}
/* }}} *//* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION*/
PHP_RINIT_FUNCTION(ncdocxml)
{return SUCCESS;
}
/* }}} *//* Remove if there's nothing to do at request end */
/* {{{ PHP_RSHUTDOWN_FUNCTION*/
PHP_RSHUTDOWN_FUNCTION(ncdocxml)
{return SUCCESS;
}
/* }}} *//* {{{ PHP_MINFO_FUNCTION*/
PHP_MINFO_FUNCTION(ncdocxml)
{php_info_print_table_start();php_info_print_table_header(2, "ncdocxml support", "enabled");php_info_print_table_end();/* Remove comments if you have entries in php.iniDISPLAY_INI_ENTRIES();
}
/* }}} *//* Remove the following function when you have succesfully modified config.m4so that your module can be compiled into PHP, it exists only for testingpurposes. *//* Every user-visible function in PHP should document itself in the source */
/* {{{ proto string confirm_ncdocxml_compiled(string arg)Return a string to confirm that the module is compiled in */
PHP_FUNCTION(confirm_ncdocxml_compiled)
{char *arg = NULL;int arg_len, len;char *strg;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {return;}len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "ncdocxml", a
rg);RETURN_STRINGL(strg, len, 0);
}
/* }}} */
/* The previous line is meant for vim and emacs, so it can correctly fold andunfold functions in source code. See the corresponding marks just beforefunction definition, where the functions purpose is also documented. Pleasefollow this convention for the convenience of others editing your code.
*//** Local variables:* tab-width: 4* c-basic-offset: 4* End:* vim600: noet sw=4 ts=4 fdm=marker* vim<600: noet sw=4 ts=4*/PHP_FUNCTION(ncdocxml)
{char *dbg = NULL;int dbg_len, len;int result;if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dbg, &dbg_len) == FAILURE){return;}result = NcXmlDocGetClass(dbg);RETURN_LONG(result);
}
############

[6] nano -w php_ncdocxml.h
############
/*+----------------------------------------------------------------------+| PHP Version 5                                                        |+----------------------------------------------------------------------+| Copyright (c) 1997-2012 The PHP Group                                |+----------------------------------------------------------------------+| This source file is subject to version 3.01 of the PHP license,      || that is bundled with this package in the file LICENSE, and is        || available through the world-wide-web at the following url:           || http://www.php.net/license/3_01.txt                                  || If you did not receive a copy of the PHP license and are unable to   || obtain it through the world-wide-web, please send a note to          || license@php.net so we can mail you a copy immediately.               |+----------------------------------------------------------------------+| Author:                                                              |+----------------------------------------------------------------------+
*//* $Id: header 321634 2012-01-01 13:15:04Z felipe $ */#ifndef PHP_NCDOCXML_H
#define PHP_NCDOCXML_Hextern zend_module_entry ncdocxml_module_entry;
#define phpext_ncdocxml_ptr &ncdocxml_module_entry#ifdef PHP_WIN32
#       define PHP_NCDOCXML_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
#       define PHP_NCDOCXML_API __attribute__ ((visibility("default")))
#else
#       define PHP_NCDOCXML_API
#endif#ifdef ZTS
#include "TSRM.h"
#endifPHP_MINIT_FUNCTION(ncdocxml);
PHP_MSHUTDOWN_FUNCTION(ncdocxml);
PHP_RINIT_FUNCTION(ncdocxml);
PHP_RSHUTDOWN_FUNCTION(ncdocxml);
PHP_MINFO_FUNCTION(ncdocxml);PHP_FUNCTION(confirm_ncdocxml_compiled);        /* For testing, remove later. */
PHP_FUNCTION(ncdocxml);/*Declare any global variables you may need between the BEGINand END macros here:     ZEND_BEGIN_MODULE_GLOBALS(ncdocxml)long  global_value;char *global_string;
ZEND_END_MODULE_GLOBALS(ncdocxml)
*//* In every utility function you add that needs to use variablesin php_ncdocxml_globals, call TSRMLS_FETCH(); after declaring othervariables used by that function, or better yet, pass in TSRMLS_CCafter the last function argument and declare your utility functionwith TSRMLS_DC after the last declared argument.  Always refer tothe globals in your function as NCDOCXML_G(variable).  You areencouraged to rename these macros something shorter, seeexamples in any other php module directory.
*/#ifdef ZTS
#define NCDOCXML_G(v) TSRMG(ncdocxml_globals_id, zend_ncdocxml_globals *, v)
#else
#define NCDOCXML_G(v) (ncdocxml_globals.v)
#endif#endif  /* PHP_NCDOCXML_H *//** Local variables:* tab-width: 4* c-basic-offset: 4* End:* vim600: noet sw=4 ts=4 fdm=marker* vim<600: noet sw=4 ts=4*/
############

[7] /usr/local/php5/bin/phpize --with-apxs2=/usr/local/apache/bin/apxs

[8] apt-get install autoconf

[9] ./configure --with-ncdocxml --with-php-config=/usr/local/php5/bin/php-config

[10] nano -w Makefile
############
/*修改*/
EXTRA_LIBS=-lncdocxml
############

[11] make clean; make LDFLAGS=-lncdocxml

[12] ldd modules/ncdocxml.so
############
    linux-gate.so.1 =>  (0xb772e000)
        libncdocxml.so => /usr/local/lib/libncdocxml.so (0xb76a5000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb755e000)
        libxml2.so.2 => /usr/local/lib/libxml2.so.2 (0xb7435000)
        libz.so.1 => /usr/local/lib/libz.so.1 (0xb741f000)
        libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7406000)
        libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb73e0000)
        /lib/ld-linux.so.2 (0xb772f000)
        libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb73dc000)
        libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0xb72fd000)
############

[13] make install
############
Installing shared extensions:     /usr/local/php5/lib/php/extensions/no-debug-zts-20090626/
############

[14] nano -w /etc/php.ini
############
extension = /usr/local/php5/lib/php/extensions/no-debug-zts-20090626/ncdocxml.so
############

[15] /usr/local/apache/bin/apachectl restart


[16] nano -w loadmoudle.php

############


<?php
if (!extension_loaded("ncdocxml")) {echo "无法加载 ncdocxml.so !".PHP_EOL;} else {echo "加载 ncdocxml.so !".PHP_EOL;
#调用加载的ncdocxml($filename)函数
$res = ncdocxml("/usr/local/test.txt");
print_r($res);
}
?>
############


[17] /usr/local/php5/bin/php /usr/local/loadmoudle.php

############

加载 ncdocxml.so !

Array(

          [0]=>success

         )

############

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/276444.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

手把手教你写个小程序定时器管理库

背景凹凸曼是个小程序开发者&#xff0c;他要在小程序实现秒杀倒计时。于是他不假思索&#xff0c;写了以下代码&#xff1a;Page({init: function () {clearInterval(this.timer)this.timer setInterval(() > {// 倒计时计算逻辑console.log(setInterval)})}, })可是&…

[New Portal]Windows Azure Virtual Machine (14) 在本地制作数据文件VHD并上传至Azure(1)

《Windows Azure Platform 系列文章目录》 之前的内容里&#xff0c;我介绍了如何将本地的Server 2012中文版 VHD上传至Windows Azure&#xff0c;并创建基于该Server 2012 VHD的虚拟机。 我们知道&#xff0c;VHD不仅仅可以保存操作系统&#xff0c;而且可以保存数据文件。 如…

python 退出程序_Python:用Ctrl+C解决终止多线程程序的问题!(建议收藏)

前言&#xff1a;今天为大家带来的内容是Python:用CtrlC解决终止多线程程序的问题&#xff01;文章中的代码具有不错的参考意义&#xff0c;希望在此能够帮助到各位&#xff01;(多数代码用图片的方式呈现出来&#xff0c;方便各位观看与收藏)出发点&#xff1a;前段时间&#…

Mysql InnoDB Plugin安装 install

转载链接&#xff1a;http://www.orczhou.com/index.php/2010/03/innodb-plugin-setup/ InnoDB Plugin较之Built-in版本新增了很多特性&#xff1a;包括快速DDL、压缩存储等&#xff0c;而且引入了全新的文件格式Barracuda。众多测试也表明&#xff0c;Plugin在很多方面优于Bu…

Hibernate的数据过滤查询

数据过滤并不是一种常规的数据查询方法&#xff0c;而是一种整体的筛选方法。数据过滤也可对数据进行筛选&#xff0c;因此&#xff0c;将其放在Hibernate的数据查询框架中介绍。 如果一旦启用了数据过滤器&#xff0c;则不管数据查询&#xff0c;还是数据加载&#xff0c;该过…

若川知乎高赞:有哪些必看的 JS 库?

欢迎星标我的公众号&#xff0c;回复加群&#xff0c;长期交流学习我的知乎回答目前2w阅读量&#xff0c;270赞&#xff0c;现在发到公众号声明原创。必看的js库&#xff1f;只有当前阶段值不值看。我从去年7月起看一些前端库的源码&#xff0c;历时一年才写了八篇《学习源码整…

python用for循环求10的因数_python for循环练习(初级)

for循环练习1for i in range(4):print(i)D:\尚硅谷Python\venv\Scripts\python.exe D:/尚硅谷Python/test.py0123for循环练习2for x in range(1,40,5): #间隔5print(x)D:\尚硅谷Python\venv\Scripts\python.exe D:/尚硅谷Python/test.py16111621263136打印99乘法表for i in ran…

基于EasyUI的Web应用程序及过去一年的总结

前言 一个多月之前已经提交了离职申请&#xff0c;好在领导都已经批准了&#xff0c;过几天就办理手续了&#xff0c;在此感谢领导的栽培与挽留&#xff0c;感谢各位同事在工作中的给我的帮助&#xff0c;离开这个团队确实有一些不舍&#xff0c;不为别的&#xff0c;只因为这个…

MySQL外键创建失败1005原因总结

1、安装mysql有InnoDB的插件扩展 ./configure --prefix/usr/local/mysql --with-pluginscsv,innobase,myisam,heap,innodb_plugin 2、找不到主表中 引用的列 3、主键和外键的字符编码不一致 4、外键字段与要做外键校验的字段类型不匹配 5、MySQL支持外键约束&#xff0c;并…

Hibernate的事件机制

4.8 事 件 机 制 通常&#xff0c;Hibernate执行持久化过程中&#xff0c;应用程序无法参与其中。所有的数据持久化操作&#xff0c;对用户都是透明的&#xff0c;用户无法插入自己的动作。 通过事件框架&#xff0c;Hibernate允许应用程序能响应特定的内部事件&#xff0c;从而…

快速使用Vue3最新的15个常用API

之前我写了一篇博客介绍了Vue3的新特性&#xff0c;简单了解了一下Vue3都有哪些特色&#xff0c;并且在文末带大家稍微体验了一下Vue3中 Compsition API 的简单使用上一篇文章地址&#xff1a;紧跟尤大的脚步提前体验Vue3新特性&#xff0c;你不会还没了解过Vue3吧因为这个月的…

超级马里奥代码_任天堂的源码泄露,揭示超级马里奥的前世之生

被黑客盯上的任天堂任天堂遭到了史上最大规模的黑客攻击&#xff0c;Wii 完整源码、设计以及《宝可梦》多部作品的信息遭到泄露&#xff0c;而此次泄露事件的后续影响似乎也爆发了出来。《马里奥赛车》和《超级马里奥世界2》(耀西岛)的早期原型视频&#xff0c;以及《超级马里奥…

行者寂寞

公元2009年7月20日。闰五月廿八。炎日&#xff0c;汗如雨。晨行。病卧于京西客站。是夜&#xff0c;不能寐。 公元2009年7月21日。闰五月廿九。戏于清华&#xff0c;游于星巴克。汗如雨。是夜&#xff0c;困于京国际机场5小时。 公元2009年7月22日。六月初一。晨时抵宁。大雨。…

Azure PowerShell (1) PowerShell整理

《Windows Azure Platform 系列文章目录》 把之前Azure ASM的PowerShell都整理好了。 https://github.com/leizhang1984/AzureChinaPowerShell

漫画 | 前端发展史的江湖恩怨情仇

时间总是过得很快&#xff0c; 似乎快得让人忘记了昨天&#xff0c;前端WEB领域的发展更是如此&#xff0c;转眼间已是近30年&#xff0c;时光荏苒&#xff0c;初心不变&#xff0c;在一代又一代前端人的努力下&#xff0c;前端已经是互联网不可或缺的一部分。然而很多前端打工…

jquery1.9 下检测浏览器类型和版本

原文链接&#xff1a;http://blog.csdn.net/lyc_2011_acm/article/details/8749177 Jquery1.9版本中$.browser已被剔除&#xff1a; 判断浏览器类型&#xff1a; $.browser.mozilla /firefox/.test(navigator.userAgent.toLowerCase()); $.browser.webkit /webkit/.test(nav…

python可迭代对象 迭代器生成器_Python可迭代对象、迭代器和生成器

8.1 可迭代对象(Iterable)大部分对象都是可迭代&#xff0c;只要实现了__iter__方法的对象就是可迭代的。__iter__方法会返回迭代器(iterator)本身&#xff0c;例如&#xff1a;>>> lst [1,2,3]>>> lst.__iter__()Python提供一些语句和关键字用于访问可迭代…

Windows Mobile下使用CppUnitLite输出测试结果

背景 TDD测试驱动开发是当前流行的开发方法及模式。遵循TDD的方法对开发程序库(Library)特别有用&#xff0c;因为Library就是为第三方提供一定功能接口的实现&#xff0c;使用TDD的方法可以预先为定义的接口提供测试案例&#xff0c;保证实现代码能通过测试&#xff0c;保证Li…

sql注意事项2点

①对Null的判断,如果要用<>与null判断,则都会得到否定结果②insert into时,要把字段显示指出,不然会因字段位置变化出错③-一个数时,如果有可能存在Null,则结果会被置为Null解决方法,select出来的结果,最好加isnull判断转载于:https://www.cnblogs.com/lishenglyx/archiv…

PHP IE中下载附件问题

重点&#xff1a; 1、在IE中下载附件之前要清空缓存。 2、中文文件名要用urlencode编码。 Header("Pragma: "); //不加的话&#xff0c;IE中会提示目标主机无法访问 Header("Cache-Control: "); //不加的话&#xff0c;IE中会提示目标…