The following examples illustrate the use of SWIG with Perl.
% swig -perl5 interface.i
% swig -perl5 interface.i % gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c % gcc -shared interface_wrap.o $(OBJS) -o interface.so % perl use interface; ...
The most recent version of Perl used for testing is as follows:
% perl -version This is perl, v5.6.0 built for sun4-solaris Copyright 1987-2000, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.
Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows, the code generated by SWIG is extremely messy. We have made every attempt to maintain compatibility with many Perl releases going as far back as 5.003 and as recent as 5.6. However, your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. Better yet, send us a patch.