SWIG

From Lazarus wiki
Revision as of 12:34, 19 July 2013 by BigChimp (talk | contribs) (binary downloads)
Jump to navigationJump to search

Overview

SWIG is a program that takes C++ .h and .cpp files and generates object-oriented language bindings for various languages.

Object Pascal support

The main SWIG tree does not support Delphi/Object Pascal.

Some years ago, Stefano Moratti wrote a Delphi adapter for the SWIG code which allows automatic translation of C++ libraries into Delphi mode Object Pascal. [1] His patches were not integrated into mainstream SWIG, but they have been used, e.g. to create a Delphi binding for GDAL: [2]

In 2012, FPC mailing list user d.l.i.w. adapted the original Delphi patches to the more recent SWIG 2.0.8 source but unfortunately forgot to do it in a version-controlled repository. See here: [3] and more about functionality: [4]

Unfortunately, there have bee no further efforts to incorporate this into current SWIG trunk.

Download source

To at least help preserver the work, the complete set of 2.0.8 files is uploaded at:

Compiling

On Linux, do e.g. this (run on Debian Linux; adjust paths etc as necessary:

Compiling swig on a debian system:
su -
aptitude -y install yodl mercurial #yodl needed for man page install
# mercurial needed to get the swig sources from the bitbucket repository
# alternatively download, extract etc
exit #to regular user, called pascaldev on this system

cd ~
hg clone https://reiniero@bitbucket.org/reiniero/smalltools
cd ~/smalltools/SWIGDelphi/swig-2.0.8

# configure:
chmod ug+x configure
# tell it to install in user's home directory; adjust as necessary
mkdir ~/swig
./configure --prefix=/home/pascaldev/swig

#compile:
make

#install:
chmod ug+rx Tools/config/install-sh
make install

#should be installed in ~/swig now; e.g. ~/swig/bin/swig should work
~/swig/bin/swig -version

Download

Linux x64 binaries compiled via the procedure above:

Development

It would of course be very welcome if somebody

  • got the current version into main SWIG so it is more easily usable
  • improve the code

Additionnally, binary releases for e.g. Linux and Windows are warmly welcome for upload to e.g. the BitBucket repository. Please contact forum user BigChimp for that.