osdir.com
mailing list archive

Subject: swig php simple example - msg#00049

List: programming.swig

Date: Prev Next Index Thread: Prev Next Index
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



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: problems with perl on mac os x

Scott Murman wrote: Ok, solved part of my problems. the "shared" library must be named example.bundle, not example.so under os x. i reported this several months back, but apparently it hasn't made it into the distrib yet. I've changed the configure script to output example.bundle when compiling the examples under darwin. You may want to check the examples using the cvs version of SWIG. Cheers William _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Next Message by Date: click to view message preview

%inline causes multiple definition

I'm working with Python 2.2 and SWIG 1.3.17. I'm trying to access a global array of strings, that looks like this: extern char *domsMsgCharFieldNames[]; I want to be able to have it access from Python. Something like this: print domsmisc_doms.cvar.domsMsgCharFieldNames[0] In the SWIG and Python manual, section 19.5.1 suggests that I can do this with "%inline". So I added this code: %inline %{ /* make FieldNames accessible */ char *domsMsgCharFieldNames_get (char *stringArray[], int index) { if (index < domsMsgCharFieldCount) return domsMsgCharFieldNames[index]; else return NULL; /* out of bounds returns NULL. */ } %} This may be doing (mostly) the right thing, but it won't compile because SWIG is also generating a definition for domsMsgCharFieldNames_get (that just returns a swig pointer to the whole array). The compile dies with: "redefinition of `_wrap_domsMsgCharFieldNames_get'". Is there a way to have %inline override the default function? -Dan _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Previous Message by Thread: click to view message preview

Python "help(swig_mod)" -> core dump

I'm using SWIG 1.3.17u with Python 2.2 (from RedHat 7.3). If I do "help (doms)", and doms is a swig generated module; the python core dumps. I know that the doc system is non-existant right now. But, is there a way to avoid causing python to fault? -Dan _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Next Message by Thread: click to view message preview

%inline causes multiple definition

I'm working with Python 2.2 and SWIG 1.3.17. I'm trying to access a global array of strings, that looks like this: extern char *domsMsgCharFieldNames[]; I want to be able to have it access from Python. Something like this: print domsmisc_doms.cvar.domsMsgCharFieldNames[0] In the SWIG and Python manual, section 19.5.1 suggests that I can do this with "%inline". So I added this code: %inline %{ /* make FieldNames accessible */ char *domsMsgCharFieldNames_get (char *stringArray[], int index) { if (index < domsMsgCharFieldCount) return domsMsgCharFieldNames[index]; else return NULL; /* out of bounds returns NULL. */ } %} This may be doing (mostly) the right thing, but it won't compile because SWIG is also generating a definition for domsMsgCharFieldNames_get (that just returns a swig pointer to the whole array). The compile dies with: "redefinition of `_wrap_domsMsgCharFieldNames_get'". Is there a way to have %inline override the default function? -Dan _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by