Trying to Load Compiled Extension

[email protected] (Nicholas Williams)
Newsgroups php.pecl.dev
Message-ID <[email protected]>
Hello, fellow developers:

Information, documentation and tutorials about creating PHP extensions 
online is rather scarce, but I was able to pull together a few tutorials 
and build an extension. You can download and view the source code from 
http://www.dnscrawler.com/rawsockets.tar.gz. I compile it as follows:

phpize
./configure --with-rawsockets
make
make install

for RedHat EL 5 and

phpize
./configure --with-rawsockets --with-php-config=/usr/bin/php-config
make
make install

for Mac OS X Snow Leopard 10.6.2. It compiles without error and says 
that the extension has been copied to the proper directory. However, if 
I try to load the extension either with dl('rawsockets.so') or 
extension=rawsockets.so in the INI file, I get the error "PHP Warning:  
PHP Startup: Invalid library (maybe not a PHP library) 'rawsockets.so'  
in Unknown on line 0 phpinfo()". If, per some suggestions I found 
online, I try to load it with 
zend_extension=/usr/lib/php5/extensions/rawsockets.so, I get the error 
"/usr/lib/php5/extensions/rawsockets.so doesn't appear to be a valid 
Zend extension."

I'm going to back off a bit on this and start with a simple "Hello, 
World" extension (I know, I probably should have done that first), but 
while I do that, I would really appreciate some input as to why this 
compiles without any errors OR warnings but doesn't load with a cryptic, 
unhelpful error message.

I did run `strace php -i` and got the following output related to my 
extension:

open("/usr/lib/php5/extensions/rawsockets.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 
\3\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=7757, ...}) = 0
mmap2(NULL, 8212, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) 
= 0xb7b6c000
fadvise64(3, 0, 8212, POSIX_FADV_WILLNEED) = 0
mmap2(0xb7b6d000, 8192, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0xb7b6d000
close(3)                                = 0
mprotect(0xb7b6d000, 4096, PROT_READ)   = 0
munmap(0xb7b6c000, 8212)                = 0
write(2, "PHP Warning:  PHP Startup: Inval"..., 107PHP Warning:  PHP 
Startup: Invalid library (maybe not a PHP library) 'rawsockets.so'  in 
Unknown on line 0
) = 107

Thanks for your help in advance,

Nick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.