Jeff Abrahamson on 22 Dec 2004 11:18:52 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

SWIG


Has anyone here successfully used swig and is able to provide a
working example?

The docs make it look pretty straight forward, but even the debian
examples (swig-example) I have had trouble getting to compile, to say
nothing of a simple example I concocted on my own.


Most illustratively, I tried the following very example from the swig
docs:

------------------------------------------------------------
/* File : example.c */

double  My_variable  = 3.0;

/* Compute factorial of n */
int  fact(int n) {
	if (n <= 1) return 1;
	else return n*fact(n-1);
}

/* Compute n mod m */
int my_mod(int n, int m) {
	return(n % m);
}
------------------------------------------------------------
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
%}

extern double My_variable;
extern int    fact(int);
extern int    my_mod(int n, int m);
------------------------------------------------------------
jeff@asterix:swig $ gcc -c example.c
jeff@asterix:swig $ swig -perl5 example.i
jeff@asterix:swig $ PERLCORE=/usr/lib/perl/5.8.4/CORE
jeff@asterix:swig $ gcc -c example.c example_wrap.c -I$PERLCORE
In file included from /usr/lib/perl/5.8.4/CORE/op.h:487,
                 from /usr/lib/perl/5.8.4/CORE/perl.h:2345,
                 from example_wrap.c:351:
/usr/lib/perl/5.8.4/CORE/reentr.h:611: error: field `_crypt_struct' has incomplete type
In file included from /usr/lib/perl/5.8.4/CORE/perl.h:3557,
                 from example_wrap.c:351:
/usr/lib/perl/5.8.4/CORE/proto.h:199: error: parse error before "off64_t"
/usr/lib/perl/5.8.4/CORE/proto.h:201: error: parse error before "Perl_do_sysseek"
/usr/lib/perl/5.8.4/CORE/proto.h:201: error: parse error before "off64_t"
/usr/lib/perl/5.8.4/CORE/proto.h:201: warning: data definition has no type or storage class
/usr/lib/perl/5.8.4/CORE/proto.h:202: error: parse error before "Perl_do_tell"
/usr/lib/perl/5.8.4/CORE/proto.h:202: warning: data definition has no type or storage class
/usr/lib/perl/5.8.4/CORE/proto.h:1308: error: parse error before "Perl_PerlIO_tell"
/usr/lib/perl/5.8.4/CORE/proto.h:1308: warning: data definition has no type or storage class
/usr/lib/perl/5.8.4/CORE/proto.h:1309: error: parse error before "off64_t"
jeff@asterix:swig $ 
------------------------------------------------------------


-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>    +1 215/837-2287
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

 A cool book of games, highly worth checking out:
 http://www.amazon.com/exec/obidos/ASIN/1931686963/purple-20

Attachment: signature.asc
Description: Digital signature


  • Follow-Ups:
    • Re: SWIG
      • From: Jeff Horwitz <jeff@sixgeeks.org>