Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vips_and_nip2_on_OS_X

John Cupitt edited this pageMar 29, 2017 ·1 revision

title: Vips and nip2 on OS Xpermalink: /Vips_and_nip2_on_OS_X/

TOC

Downloading & Installing Vips

The easiest way to get vips on a mac is to usehomebrew 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.

Using libvips in your XCode Project

These are notes from 2009 so some of the options will be different now.

For a C Project

The standard command to build a C file outlined in thehello 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 yourmain.c and selectget info. In theBuild tab, add all the output of the pkg-config command from above until the -L. In my case, it looks like this:

Xcode Preprocessor Options

Now, you can close this window. Next, go to the menu, selectProject,Edit Active Target and go to thebuild tab. We will now be looking to change the value ofOther Linker Flags, you can look for in the list, or typelinker flags in the search box to only view the relevant rows. Make sure to selectAll Configurations from theconfiguration popup on the top left so that this configuration is applied for both debug and release versions of your program.

Xcode Linker Options

Double click on theOther Linker Flags row, click on the little+ symbol at the bottom and paste the second part of thepkg-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 folderHere but obviously if you have a different system configuration it might not work.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp