Vips_and_nip2_on_OS_X
TOC
The easiest way to get vips on a mac is to use homebrew install it as per the instructions on that page, (they change occasionally so anything here would go out of date), then run:
brew install vips
When it's done, you're good to go.
These are notes from 2009 so some of the options will be different now.
The standard command to build a C file outlined in the hello world examples is the following:
gcc -Wall try5.c `pkg-config vips-7.18 --cflags --libs`
Here it is noticeable that we are passing in some arguments to gcc which are system dependent. pkg-config actually inserts system dependent compiler options on the command line so that gcc is able to find the header files and appropriate libraries for the source file you are trying to compile.
Running the following in your Terminal will actually show you what these system dependent options are
pkg-config vips-7.18 --cflags --libs
In my case, the output is the following
-D_REENTRANT -fopenmp -D_THREAD_SAFE -I/opt/local/include -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include/libxml2 -I/opt/local/include/ImageMagick -I/opt/local/include/liboil-0.3 -I/opt/local/include/OpenEXR
-I/opt/local/include/pango-1.0 -I/opt/local/include/libpng12 -I/opt/local/include/freetype2 -L/opt/local/lib -lvips -ltiff
-ljpeg -lstdc++ -lxml2 -lgthread-2.0 -lfftw3 -lMagickWand -loil-0.3 -llcms -lIlmImf -lImath -lHalf -lIex -lIlmThread
-lpangoft2-1.0 -lpng12 -lexif -lMagickCore -lpango-1.0 -lm -lfontconfig -lexpat -lfreetype -lz -lgobject-2.0 -lgmodule-2.0
-lglib-2.0 -lintl -liconv
There are basically two things its doing 1. With the -I's, its including a lot of folders to our include path for the preprocessor 2. With the -L's, its including the libraries which we need to link in Keep this terminal window open, we are going to need this command's output soon.
In Xcode, right click on your main.c and select get info. In the Build tab, add all the output of the pkg-config command from above until the -L. In my case, it looks like this:
Now, you can close this window. Next, go to the menu, select Project, Edit Active Target and go to the build tab. We will now be looking to change the value of Other Linker Flags, you can look for in the list, or type linker flags in the search box to only view the relevant rows. Make sure to select All Configurations from the configuration popup on the top left so that this configuration is applied for both debug and release versions of your program.
Double click on the Other Linker Flags row, click on the little + symbol at the bottom and paste the second part of the pkg-config output. (Should start with -L/opt/local/lib) Click ok and you're done.
Build & Run should now work. If it doesn't or you just can't be bothered to do all this yourself, you can download my project folder Here but obviously if you have a different system configuration it might not work.