Skip to content

Compiling SWIG from source

bendwr edited this page Sep 30, 2022 · 4 revisions

Ubuntu

git clone https://github.com/swig/swig.git swig-git-master
cd swig-git-master
wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
./Tools/pcre-build.sh
./autogen.sh
./configure --prefix=/usr
make
sudo make install
sudo ldconfig
cd ../
# check SWIG version
swig -version

macOS

install Developer Tools

# open Terminal, execute:
xcode-select --install

# then install Homebrew (https://brew.sh/) and then:
brew install autoconf automake libtool
# test
autoconf --version
gcc --version

install dependencies

# use whatever you need from Homebrew library, this is an example using PHP8.0
brew install httpd [email protected] cmake pkg-config fcgi gd gdal geos giflib postgresql proj protobuf-c

upgrade to recent SWIG

git clone https://github.com/swig/swig.git swig-git-master
cd swig-git-master
curl -L -O https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
./Tools/pcre-build.sh
./autogen.sh
./configure
make
sudo make install
cd ..

check SWIG version

swig -version

clone and setup MapServer 8.0

git clone https://github.com/mapserver/mapserver.git
# then point to MapServer directory
cd mapserver
# checkout branch you want (example using 8.0)
git checkout rel-8-0-0

running cmake

# while pointing in mapserver directory
cd mapserver
# create build directory
mkdir build
cd build
# link the PHP version you use (example using PHP8.0)
brew link [email protected]
# run cmake build with desired specifications (example is for PHP8.0 with SWIG)
cmake ..  -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DWITH_CLIENT_WFS=ON -DWITH_CLIENT_WMS=ON -DWITH_CURL=ON -DWITH_FCGI=ON -DWITH_FRIBIDI=OFF -DWITH_GDAL=ON -DWITH_GEOS=ON -DWITH_HARFBUZZ=OFF -DWITH_KML=ON -DWITH_OGR=ON -DWITH_POSTGIS=ON -DWITH_PROJ=ON -DWITH_PYTHON=OFF -DWITH_SOS=ON -DWITH_WFS=ON -WITH_CAIRO=ON -DCMAKE_SKIP_RPATH=ON -DWITH_PHPNG=ON -DCMAKE_INCLUDE_PATH="/usr/local/Cellar/postgresql"

# if there are no errors, run make
make
# if there are no errors, run make install
make install
Clone this wiki locally