Vips and nip2 on OS X
From VipsWiki
This page outlines some things I found out when trying to use vips and nip2 on Mac OS X 10.6. If you have better ways of doing any of the following, please email me me so I can update this page. As of today, I have still not managed to get nip2 to compile on OS X.
Contents |
Downloading & Installing Vips
In order not to have to worry about all the dependencies in getting vips for your Mac, you should use Macports. You can download it here: http://www.macports.org/install.php After having installed it, I suggest you also download and install Porticus http://porticus.alittledrop.com/ which is a nice GUI to Macports. Open porticus, search for vips in the search box (as shown on screenshot, select it and click install (top left, greyed out on my screenshot since it's already installed on my system).
This might take a while since it's also going to download and build all the dependencies for Vips (i.e. fftw-3, glib2) which could take a very long time!
When it's done, you're good to go.
Using libvips in your XCode Project
For a C Project
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.



