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.pswp.cn/news/276444.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/276444.shtml
英文地址,請注明出處:http://en.pswp.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中會提示目標…