[nycphp-talk] problems loading a custom, shared extension
Jonathan
hendler at simmons.edu
Thu Dec 8 00:28:04 EST 2005
I need help figuring out an error when writing/loading a custom, shared
extension (.so) for PHP.
Could anyone help or recommend good links, books, or other mailing lists
for developing in C to extend PHP?
I have "Building Custom PHP Extensions" by Blake Schwendiman and
"Advanced PHP Programming" by George Schlossnagle (9432 times mentioned
on this list). Both excellent books which got me started, but looking
for more information. I've been around the Zend Dev site and
http://talks.php.net/ (http://www.zend.com/apidoc/ as well) but I am stuck.
Thank you.
Background:
-------------
I am writing a script in C that uses shared memory and/or memory-mapped
files to (attempt to) speed up some frequently used PHP functionality.
I need to test the speed of the extension (using some apache "ab"
scripts) in environments where the extension will be loaded via the ini
rather than being compiled into php.
Summary of Problem:
----------
The extension will compile into PHP 4.4.1 and runs without issue as a
compiled-in extension.
I can build it into a shared object using phpize for both 4.4.1 source
and the 4.3.11 binaries.
I get no errors running phpize.
In both the PHP.INI context and dl() context the only error message is
( it can, at least, find the .so):
"PHP Warning: Unknown(): Invalid library (maybe not a PHP library)
'my_ext.so' in Unknown on line 0"
Details:
-----------
Linux, Fedora Core 4. GCC 4.0.x
dl() fails to load the .so in CLI with php of the same version (perhaps
it fails because it is already an internal extension?)
dl() AND loading through the INI fail in a server (Apache 2.0.x) with a
different version of php (4.3.11) . php.ini.
(I run phpize that is included with the precompiled 4.3.11 and added the
3 headers it needs. )
Only error message is at load time ( it can, at least, find the .so):
"PHP Warning: Unknown(): Invalid library (maybe not a PHP library)
'my_ext.so' in Unknown on line 0"
My only guesses are that :
- something do with my m4 file -
maybe the PHP_EXTENSION macro since it wasn't present in my m4 file
but PHP_NEW_EXTENSION is.
Also I see differences in documentation about PHP_SUBST(xxx_SHARED_LIBADD)
from winstead's talk:
PHP_SUBST(TIDY_SHARED_LIBADD)
PHP_EXTENSION(tidy, $ext_shared)
dnl PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared)
"PHP_EXTENSION(modulename, [shared])This macro is a /must/ to call for
PHP to configure your extension. You can supply a second argument in
addition to your module name, indicating whether you intend
compilation as a shared module. This will result in a definition at
compile time for your source as COMPILE_DL_<modulename>."
- something to do with dl() not allowing certain kinds of functionality
of an .so
- also in the m4 file I am not clear whether to use --enable or --with .
I have several source files, but using enable works fine with built in
extension.
- the standard distro doesn't let me run buildconf (even with --force it
fails), so will my updated m4 get put into configure?
- the .so has to be compiled for each and every version of PHP (doesn't
seem right )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051208/f7ec0e45/attachment.html>
More information about the talk
mailing list