SWIG: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: SWIG
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## Overview | |
| 2 | + | ||
| 3 | + | [SWIG](http://swig.org/) is a program that takes C++ .h and .cpp files and generates object-oriented language bindings for various languages. | |
| 4 | + | ||
| 5 | + | ## Object Pascal support | |
| 6 | + | ||
| 7 | + | The main SWIG tree does not support Delphi/Object Pascal. | |
| 8 | + | ||
| 9 | + | 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](http://downloadit.pf-control.de/dl.php?ref=swig) His patches were not integrated into mainstream SWIG, but they have been used, e.g. to create a Delphi binding for GDAL: [2](http://article.gmane.org/gmane.comp.programming.swig.devel/18297) | |
| 10 | + | ||
| 11 | + | 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](http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg30422.html) and more about functionality: [4](http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg30349.html) | |
| 12 | + | ||
| 13 | + | Unfortunately, there have been no further efforts to incorporate this into current SWIG trunk. Additionally, FPC developers have indicated that they prefer C++ binding support to being in FPC itself but no work is being done on this currently. | |
| 14 | + | ||
| 15 | + | UPDATE 2017: There is a SWIG 3.0.11 for Delphi and Object Pascal: [5](http://www.fmxexpress.com/create-wrapper-interfaces-for-c-and-c-libraries-using-swig-with-delphi-support/) | |
| 16 | + | ||
| 17 | + | UPDATE 2020: The version from this repo didn't build: [6](https://github.com/FMXExpress/swig-delphi) | |
| 18 | + | ||
| 19 | + | But the one from this repo did: [7](https://github.com/lynxnake/swig) | |
| 20 | + | ||
| 21 | + | I didn't test if it works or not. But I just want to share it with you. | |
| 22 | + | ||
| 23 | + | The last commit was from 2017, it seemed he abandoned it. | |
| 24 | + | ||
| 25 | + | Glad if it worked for you. But don't expect much from it! I think we need a paid professional fully working on it to bring it up to speed with upstream and eventually merge it to upstream. | |
| 26 | + | ||
| 27 | + | ## Download source | |
| 28 | + | ||
| 29 | + | The complete set of 2.0.8 files is uploaded at [8](https://dliw.pfweb.eu/dl.php?ref=swig) and [9](https://bitbucket.org/reiniero/swigdelphi/src). | |
| 30 | + | ||
| 31 | + | An on going effort of 3.0.11 files [10](http://www.fmxexpress.com/wp-content/uploads/swig-delphi.7z) and [11](https://github.com/FMXExpress/swig-delphi). | |
| 32 | + | ||
| 33 | + | Recent 4.0.0 try [12](https://github.com/lynxnake/swig) | |
| 34 | + | ||
| 35 | + | ## Compiling | |
| 36 | + | ||
| 37 | + | In the configure step, it doesn't hurt to specify | |
| 38 | + | ||
| 39 | + | ``` bash | |
| 40 | + | --with-delphi=yes | |
| 41 | + | ``` | |
| 42 | + | ||
| 43 | + | , to indicate you want support for Object Pascal. | |
| 44 | + | ||
| 45 | + | On Linux, do e.g. this (run on Debian Linux; adjust paths etc as necessary: | |
| 46 | + | ||
| 47 | + | ``` bash | |
| 48 | + | su - | |
| 49 | + | aptitude -y install build-essential yodl byacc mercurial | |
| 50 | + | # build-essential has compilers | |
| 51 | + | # yodl needed for man page install | |
| 52 | + | # byacc apparently needed at least on Debian x86 | |
| 53 | + | # mercurial needed to get the swig sources from the bitbucket repository | |
| 54 | + | # alternatively download, extract etc | |
| 55 | + | exit #to regular user, called pascaldev on this system | |
| 56 | + | ||
| 57 | + | cd ~ | |
| 58 | + | hg clone https://bitbucket.org/reiniero/swigdelphi | |
| 59 | + | cd ~/swigdelphi/swig-2.0.8 | |
| 60 | + | ||
| 61 | + | # configure: | |
| 62 | + | chmod ug+rx configure | |
| 63 | + | # tell it to install in user's home directory; adjust as necessary | |
| 64 | + | mkdir ~/swig | |
| 65 | + | ./configure --with-delphi=yes --prefix=/home/pascaldev/swig | |
| 66 | + | ||
| 67 | + | #compile: | |
| 68 | + | make | |
| 69 | + | ||
| 70 | + | #install: | |
| 71 | + | chmod ug+rx Tools/config/install-sh | |
| 72 | + | make install | |
| 73 | + | ||
| 74 | + | #should be installed in ~/swig now; e.g. ~/swig/bin/swig should work | |
| 75 | + | ~/swig/bin/swig -delphi -version | |
| 76 | + | ``` | |
| 77 | + | ||
| 78 | + | ## Download | |
| 79 | + | ||
| 80 | + | Version for Delphi which cannot be compiled now: <https://github.com/FMXExpress/swig-delphi> | |
| 81 | + | ||
| 82 | + | Version which can be compiled: <https://github.com/lynxnake/swig> | |
| 83 | + | ||
| 84 | + | ## Development | |
| 85 | + | ||
| 86 | + | It would of course be very welcome if somebody | |
| 87 | + | ||
| 88 | + | - got the current version into main SWIG so it is more easily usable | |
| 89 | + | - improve the code | |
| 90 | + | ||
| 91 | + | 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. | |
| 92 | + | ||
| 93 | + | ## See also | |
| 94 | + | ||
| 95 | + | - [SWIG project homepage](http://swig.org/) | |
| 96 | + | - [[Pascal for C++ users]] | |
| 97 | + | - [Latest SWIG 3.0 for Delphi development](http://www.fmxexpress.com/create-wrapper-interfaces-for-c-and-c-libraries-using-swig-with-delphi-support/) | |
| 98 | + | ||
| 99 | + | --- | |
| 100 | + | *From the Free Pascal wiki, page "SWIG", as it stood on 2022-10-21 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 101 | + | Category: C++ | |
| 102 | + | Category: FPC |
