How to compile libvips on OSX from source for image processing
Here are the steps needed to compile libvips from source. If you try to install it from homebrew, you will most likely run into a number of errors regarding the dependency gtk-doc. This will frustrate you, and you might abandon the effort. I will show you how to install the latest stable libvips without having to install gtk-doc
I normally do not like to use dependencies like this in my Go project, but the performance of image processing needs to be really good as this type of computing tends to use a ton of resources on a server.
There are a number of homebrew installs you can use to speed this process up. Before we get started, make sure you have XCode installed along with the command line tools. Also make sure you have homebrew installed. Then follow these steps to build libvips on osx.
0. brew install autoconf automake libtool
First install libxml2
- brew install libxml2
Next run this command as root to link the installed libxml2
- sudo brew link libxml2
check that /usr/local/lib/ has entries for libxml2 pointing to your homebrew area also check that
/usr/local/include/libxml2 points to your homebrew install of libxml2
Now install the nasm
- brew install nasm
Now you want to download and compile libjpeg-turbo
-
cd into that folder and run the following commands:
autoreconf -fiv
./configure
make
sudo make install
check that the install places the files under /opt/libjpeg-turbo/
6. cd to your general git folder where you keep all cloned source and clone libvips source
git clone https://github.com/jcupitt/libvips
7. assuming that libxml2 in step 2 is in expected area and libjpeg-turbo in step 5 is in expected area cd into the cloned source of libvips and run the following commands
./configure –with-jpeg-libraries=/opt/libjpeg-turbo/lib –with-jpeg-includes=/opt/libjpeg-turbo/include CFLAGS=”-I/usr/local/include/libxml2″ LDFLAGS=”-L/usr/local/lib”
make
sudo make install
- Finally check everything was installed by going to /usr/local/lib if you see the libvips with recent timestamps you have installed from source libvips on osx