日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

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

發布時間:2023/12/9 php 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

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

<?phpif (!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

???????? )

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

總結

以上是生活随笔為你收集整理的PHP5加载|安装外部C动态库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。