Setup A More Recent Version Of Swig

Older versions of swig don’t work with the latest version of nodejs.

To setup a patched version of swig, we will pull from master and build. We will install in /usr/local because that is the standard installation target for linux - when installing packages which are custom built.

remove old swig versions form your machine :

sudo apt purge swig*
sudo rm -rf /usr/local/swig*

Installing pre-requisites

dpkg -S yacc
sudo apt install bison libpcre3-dev

Configure & install swig

First clone the required repo (use a depth of 1 to save bandwidth) :

git clone --depth=1 https://github.com/swig/swig.git

Now configure :

cd swig
./autogen.sh

If you get problem aclocal: not found, do install these tools first :

sudo apt install autotools-dev automake

then, run autogen.sh again

./configure --with-jsv8inc=/usr/include/node --with-jsv8lib=/usr/lib/x86_64-linux-gnu --prefix=/usr/local/swig-git-master

If it’s getting error :

configure: error: 
        Cannot find pcre2-config script from PCRE2 (Perl Compatible Regular Expressions)

Retry add --without-pcre

./configure --with-jsv8inc=/usr/include/node --with-jsv8lib=/usr/lib/x86_64-linux-gnu --prefix=/usr/local/swig-git-master --without-pcre

Now build :

make -j4

Now install, make sure you link the swig executable to the /usr/local/bin directory so you can call it from the command line :

sudo make install
sudo ln -s /usr/local/swig-git-master/bin/* /usr/local/bin

Comments