How to setup FreeImage & ImageScience
This article details the steps necessary to download and compile FreeImage as well as ImageScience for use within Ruby on Rails apps.
1) First, download FreeImage. You can download this into a directory of your choosing. An appropriate place for this might be /opt/local/src:
# mkdir -p /opt/local/src # cd /opt/local/src
When prompted for a password, just press 'Enter'.
# cvs -z3 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage login # cvs -z3 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage co -P FreeImage # cd FreeImage
2) Now we need to edit the Makefile to tweak a few settings that affect how FreeImage is compiled.
nano -w Makefile.solaris
3) Near the top of the file, look for #General configuration variables. Change the following lines so that it looks like this:
# General configuration variables: CC = gcc CPP = g++ AR = /usr/ccs/bin/ar INSTALLDIR = /opt/local/include
Look for the line that starts COMPILERFLAGS, and change it to look like this:
COMPILERFLAGS = -O3 -DBYTE_ORDER=BIG_ENDIAN -D__BIG_ENDIAN__
Towards the end of the file, find the line that begins install:, and change it and the following lines to look like this:
install: install -m 644 -u root -g root -f $(INSTALLDIR) Source/FreeImage.h install -m 644 -u root -g root -f $(INSTALLDIR) $(STATICLIB) install -m 755 -u root -g root -f $(INSTALLDIR) $(SHAREDLIB)
Makefile.solaris:60: *** missing separator. Stop.
Save this file by pressing CTRL+O and exit by pressing CTRL+X.
4) Now create the directories that FreeImage will be installed to:
# mkdir -p /opt/local # mkdir -p /opt/local/include
5) Begin the compiling/install process:
# gmake -f Makefile.solaris # gmake -f Makefile.solaris install
Congratulations, FreeImage has been compiled/installed!
6) Now, we need to install ImageScience, and the RubyInline gem (since it's required by ImageScience).
# gem install RubyInline image_science
