Mar 30, 2009

Running a project that uses Imagemagick library in eclipse

Download the imagemagick from ImageMagick site

Install it. Then we have to set several environment variables.

export MAGICK_HOME="/Users/reza/Desktop/Image-Magick-6.4.8" // location in my computer :)
export PATH="$MAGICK_HOME/bin:$PATH"
export LD_LIBRARY_PATH="$MAGICK_HOME/lib"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"

We can set it into the /usr/etc/profile bash file. So that each time computer starts up it automatically loads the environment variables.

Now execute the following commands.

convert logo: logo.gif
identify logo.gif
display logo.gif


If everything is ok then we will be able to see an image.

Now we have to add copy the Magick++, magick, wand folders and Magick++.h file of the include folder into the /usr/include.

If we use any of the imagemagick library files we have to set the linker the path of the folder that contains all the dylibs(libMagick.dylib, libMagickCore.dylib ..).
Open the project properties option in eclipse. Then go to C/C++ Build->Settings->Tool Settings->Libraries.

Now add the needed library file name into Libraries(-l) option and Path of the Image magick lib folder into the Library search path(-L) option.
For example if you need Magick++ and MagickCore libraries then add Magick++ and MagickCore into the libraries option and /$MAGICK_HOME/lib into the Library search path option.

Set up the run configuration and our project is ready to run.

No comments:

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...