Harish Murthy | 1 Nov 2003 01:32

problem with example (php)

Hi ,

I tried running the example under /SWIG-1.3.19/Examples/php4/simple/
and I get the example.so , but when I run the runme.php4,  I get the
below error,
PHP Warning:  dl() [http://www.php.net/function.dl]: Unable to load 
dynamic library './example.so' - ./example.so: cannot open shared object 
file: No such file or directory in 
/SWIG-1.3.19/Examples/php4/simple/example.php on line 19
PHP Fatal error:  Call to undefined function:  gcd() in 
/SWIG-1.3.19/Examples/php4/simple/runme.php4 on line 9

I did the following steps to get the .so

phpize
./configure
make
make install

Kindly advise...
Thanks
Harish

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Youichi Iwakiri | 1 Nov 2003 03:22
Picon

Re: problem with example (php)

Hi, Harish

I have coped with it by applying following patch.
For details, please see http://bugs.php.net/bug.php?id=25183

--

-- 
Youichi Iwakiri

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Sam Liddicott | 1 Nov 2003 18:01

Re: problem with example (php)

Harish Murthy wrote:

> Hi ,
>
> I tried running the example under /SWIG-1.3.19/Examples/php4/simple/
> and I get the example.so , but when I run the runme.php4,  I get the
> below error,
> PHP Warning:  dl() [http://www.php.net/function.dl]: Unable to load 
> dynamic library './example.so' - ./example.so: cannot open shared 
> object file: No such file or directory in 
> /SWIG-1.3.19/Examples/php4/simple/example.php on line 19
> PHP Fatal error:  Call to undefined function:  gcd() in 
> /SWIG-1.3.19/Examples/php4/simple/runme.php4 on line 9
>
>
> I did the following steps to get the .so
>
> phpize
> ./configure
> make
> make install
>
>

Isn't this because the .so file isn't in your php library search path?
Look in your php.ini and see where it looks to load modules from/

Also look at "make test" in the generated makefile, you'll see how to 
test it we specify on the php command line where to look to find the .so

(Continue reading)

Joost van Lawick | 3 Nov 2003 19:37
Picon

C global array in Python

I am struggling to get access to a C array but no luck so far. I have read a
lot about arrays and structs in the manuals but I cannot find an example (or
answer..). I am trying to wrap a C library to be used from Python to get access
to an external comnputer interface board (K8000 Velleman). Here's part of the
.h file of the library:

  /* configuration and data matrix*/
  extern short AD_matrix[MaxChains][MaxADchannel+1];

  /* old configuration and data arrays  */
  /* they just point to the first chain */
  /* like this: IO[1] = IO_matrix[0][1] */
  extern short *AD;

and furthermore a lot of functions to set output channels or read input
channels. Data read from input channels is written into AD_matrix.

I just include this .h file into the .i file.
Then I swig around: $ swig -python -shadow k8000.i
and compile and link. So far so good.

In python I do:
>>> from k8000 import *
>>> SetAllIOChannels()    # yes! all leds are turned on
>>> ReadFromCard()        # I verified that input channel is altered
>>> print cvar.AD_matrix
_600d0240_p_a_16_1__short
>>> 

This is a string. How do I get my hands on the data?
(Continue reading)

David Beazley | 3 Nov 2003 19:43
Favicon

C global array in Python

Joost van Lawick writes:
 > I am struggling to get access to a C array but no luck so far. I have read a
 > lot about arrays and structs in the manuals but I cannot find an example (or
 > answer..). I am trying to wrap a C library to be used from Python to get access
 > to an external comnputer interface board (K8000 Velleman). Here's part of the
 > .h file of the library:
 > 
 >   /* configuration and data matrix*/
 >   extern short AD_matrix[MaxChains][MaxADchannel+1];
 > 
 >   /* old configuration and data arrays  */
 >   /* they just point to the first chain */
 >   /* like this: IO[1] = IO_matrix[0][1] */
 >   extern short *AD;
 > 
 > and furthermore a lot of functions to set output channels or read input
 > channels. Data read from input channels is written into AD_matrix.
 > 
 > I just include this .h file into the .i file.
 > Then I swig around: $ swig -python -shadow k8000.i
 > and compile and link. So far so good.
 > 
 > In python I do:
 > >>> from k8000 import *
 > >>> SetAllIOChannels()    # yes! all leds are turned on
 > >>> ReadFromCard()        # I verified that input channel is altered
 > >>> print cvar.AD_matrix
 > _600d0240_p_a_16_1__short
 > >>> 
 > 
(Continue reading)

Joost van Lawick | 3 Nov 2003 19:51
Picon

Re: C global array in Python

Thanks for the quick reply! However, when I include the inline into the .i file
I get the following error:

swig -shadow -python k8000.i
gcc -c -I/usr/local/include/python2.3 k8000_wrap.c
k8000_wrap.c:1909: redefinition of `_wrap_AD_matrix_get'
k8000_wrap.c:771: `_wrap_AD_matrix_get' previously defined here
k8000_wrap.c: In function `init_k8000':
k8000_wrap.c:2060: warning: passing arg 3 of `SWIG_addvarlink' from incompatible pointer type
make: *** [k8000_wrap.o] Error 1

Cheers,

Joost

On Mon, Nov 03, 2003 at 12:43:16PM -0600, David Beazley wrote:
> Joost van Lawick writes:
>  > I am struggling to get access to a C array but no luck so far. I have read a
>  > lot about arrays and structs in the manuals but I cannot find an example (or
>  > answer..). I am trying to wrap a C library to be used from Python to get access
>  > to an external comnputer interface board (K8000 Velleman). Here's part of the
>  > .h file of the library:
>  > 
>  >   /* configuration and data matrix*/
>  >   extern short AD_matrix[MaxChains][MaxADchannel+1];
>  > 
>  >   /* old configuration and data arrays  */
>  >   /* they just point to the first chain */
>  >   /* like this: IO[1] = IO_matrix[0][1] */
>  >   extern short *AD;
(Continue reading)

David Beazley | 3 Nov 2003 19:53
Favicon

Re: C global array in Python

Joost van Lawick writes:
 > Thanks for the quick reply! However, when I include the inline into the .i file
 > I get the following error:
 > 
 > swig -shadow -python k8000.i
 > gcc -c -I/usr/local/include/python2.3 k8000_wrap.c
 > k8000_wrap.c:1909: redefinition of `_wrap_AD_matrix_get'
 > k8000_wrap.c:771: `_wrap_AD_matrix_get' previously defined here
 > k8000_wrap.c: In function `init_k8000':
 > k8000_wrap.c:2060: warning: passing arg 3 of `SWIG_addvarlink' from incompatible pointer type
 > make: *** [k8000_wrap.o] Error 1
 > 
Oh.  You might want to pick a different name for the helper function.
Maybe

   AD_matrix_getitem()

(I think _get is already used).  oops.

- Dave
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Joost van Lawick | 3 Nov 2003 19:57
Picon

Re: C global array in Python

Thanks, it all makes out allright. I get values but have to go home first to
turn on the k8000 board! I'll let you you know if I can read the IO channels.

Cheers,

Joost

On Mon, Nov 03, 2003 at 12:53:05PM -0600, David Beazley wrote:
> Joost van Lawick writes:
>  > Thanks for the quick reply! However, when I include the inline into the .i file
>  > I get the following error:
>  > 
>  > swig -shadow -python k8000.i
>  > gcc -c -I/usr/local/include/python2.3 k8000_wrap.c
>  > k8000_wrap.c:1909: redefinition of `_wrap_AD_matrix_get'
>  > k8000_wrap.c:771: `_wrap_AD_matrix_get' previously defined here
>  > k8000_wrap.c: In function `init_k8000':
>  > k8000_wrap.c:2060: warning: passing arg 3 of `SWIG_addvarlink' from incompatible pointer type
>  > make: *** [k8000_wrap.o] Error 1
>  > 
> Oh.  You might want to pick a different name for the helper function.
> Maybe
> 
>    AD_matrix_getitem()
> 
> (I think _get is already used).  oops.
> 
> - Dave

--

-- 
(Continue reading)

Joost van Lawick | 3 Nov 2003 21:09
Picon

Re: C global array in Python

Hello,

It all works fine! I can read and write data to the k8000 board from Python.
Thanks for all the help. Looking at the additional lines in the .i, I notice in
the wrapper function a thing called 'data'. I cannot find it anywhere, so is
this a SWIG specific thing?

Cheers,

Joost

On Mon, Nov 03, 2003 at 12:53:05PM -0600, David Beazley wrote:
> Joost van Lawick writes:
>  > Thanks for the quick reply! However, when I include the inline into the .i file
>  > I get the following error:
>  > 
>  > swig -shadow -python k8000.i
>  > gcc -c -I/usr/local/include/python2.3 k8000_wrap.c
>  > k8000_wrap.c:1909: redefinition of `_wrap_AD_matrix_get'
>  > k8000_wrap.c:771: `_wrap_AD_matrix_get' previously defined here
>  > k8000_wrap.c: In function `init_k8000':
>  > k8000_wrap.c:2060: warning: passing arg 3 of `SWIG_addvarlink' from incompatible pointer type
>  > make: *** [k8000_wrap.o] Error 1
>  > 
> Oh.  You might want to pick a different name for the helper function.
> Maybe
> 
>    AD_matrix_getitem()
> 
> (I think _get is already used).  oops.
(Continue reading)

Mike Romberg | 3 Nov 2003 21:41
Picon
Favicon

python -modern switch


  I just tried out the CVS version of swig with a big swig wrapped
bunch of C++ we use here.  And I have nothing bad to report :).  In
fact the -modern switch is really great.  It produces code that is at
least as fast as swig-1.1p5.  This is great as it was the last issue I
really had after switching from 1.1p5 to the 1.3 series of SWIG.
Thanks for all the great work everyone is doing to make SWIG such a
useful tool.

Mike Romberg (mike.romberg <at> noaa.gov)
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig


Gmane