logo       
Bookmark and Share

swig php simple example: msg#00049

programming.swig

Subject: swig php simple example

I'm trying to get the simple example to work with php -- I've been using
swig for perl for some time. Searching the mailing list and swig.org hasn't
turned up any magic tricks for php. If someone can help me out, I'd be very
grateful.

The output in the web page is:

hi
Warning: dl() [function.dl]: Invalid library (maybe not a PHP library)
'example.so' in /usr/local/httpd/htdocs/test_php/test.php4 on line 3

The php file is:

<?php echo "hi"; ?>
<?php
dl("example.so");
?>

I get the same error message whether I compile directly or use phpize, and
also when I include the example.php file -- whenever I match the filename in
the example.php file with the actual .so file. (Also with runme.php4.)

I used: swig -php4 -phpfull example.i

The only thing I can see that is suspicious is that swig adds "php_" to the
front of the .h filename, and also in the example.php file it generates, but
using phpize generates example.so, not php_example.so. This is different
behavior from swig 1.3.11, which used "libexample.so" in the dl statement in
example.php.

Here's the bit in the example.php file:

if (!extension_loaded("php_example")) {
if (!dl("php_example.so")) return;
}

But I get the same message if I compile directly:

gcc -c example.c
gcc -c example_wrap.c -I/usr/local/include/php -I/usr/local/include/php/main
-I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM
gcc -shared example.so example_wrap.o -o php_example.so

I downloaded the current version of php yesterday (4.3.0), and the current
version of swig today (1.3.17). Over the weekend I was using 1.3.11. I have
gcc 2.95.3 on Linux (suse 7.2).

Thanks,

J. R.

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise