Re: configuring dynamic extensions

From: Date: Mon, 15 Mar 2004 20:58:17 +0000
Subject: Re: configuring dynamic extensions
References: 1  Groups: php.install 
Request: Send a blank email to php-install+get-12987@lists.php.net to get a copy of this message
list ----- Original Message ----- From: Randy Debasa To: Chris@nthelp.org Sent: Monday, March 15, 2004 4:02 PM Subject: RE: [PHP-INSTALL] configuring dynamic extensions What do you mean by list? I'm sorry, I don't follow. Thank you for taking the time to respond! -rdebasa -----Original Message----- From: Chris@nthelp.org [mailto:Chris@nthelp.org] Sent: Monday, March 15, 2004 11:56 AM To: Randy Debasa Subject: Re: [PHP-INSTALL] configuring dynamic extensions list ----- Original Message ----- From: Randy Debasa To: php-install@lists.php.net Sent: Monday, March 15, 2004 12:07 PM Subject: [PHP-INSTALL] configuring dynamic extensions We are using php-4.3.2 and Apache 2. Here is exactly what we did: First we created this cpp source file: ------------------------------------------------------------------ #include "php.h" /* declaration of functions to be exported */ ZEND_FUNCTION(first_module); /* compiled function list so Zend knows what's in this module */ zend_function_entry firstmod_functions[] = { ZEND_FE(first_module, NULL) {NULL, NULL, NULL} }; /* compiled module information */ zend_module_entry firstmod_module_entry = { STANDARD_MODULE_HEADER, "First Module", firstmod_functions, NULL, NULL, NULL, NULL, NULL, NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; /* implement standard "stub" routine to introduce ourselves to Zend */ #if COMPILE_DL_FIRST_MODULE ZEND_GET_MODULE(firstmod) #endif /* implement function that is meant to be made available to PHP */ ZEND_FUNCTION(first_module) { long parameter; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) { return; } RETURN_LONG(parameter); } After creating the first_module.cpp file above we compiled it and linked it using the following commands: $ g++ -fpic -DCOMPILE_DL_FIRST_MODULE=1 -I/usr/include/php/main/ -I/usr/include/php/Zend/ -I/usr/include/php/ -I/usr/include/php/TSRM/ -c -o first_module.o first_module.cpp $ g++ -shared -L/usr/local/lib -rdynamic -o first_module.so first_module.o Then, we checked in php.ini file for the extension directory (phpinfo()), which happened to be : /usr/local/lib/php/extensions/no-debug-non-zts-20020429/ We also made sure that enable_dl was On. We copied the first_module.so file into the extension directory. We then tested the first_module.so file using the following php page: <?php print("Beginning"); dl("first_module.so"); $param = 2; $return = first_module($param); print("We sent '$param' and got '$return'"); print("Done..."); ?> This is the error we are getting: Beginning Warning: dl(): Invalid library (maybe not a PHP library) 'first_module.so' in /home/randy/public_html/index.php on line 3 Fatal error: Call to undefined function: first_module() in /home/randy/public_html/index.php on line 6 Is there anything else that we need to do to be able to use a dynamic loadable module?? Any help will be greatly appreciated!!! -rdebasa

« previous php.install (#12987) next »