Freeimage/image_science on leopard


#1

---------- Forwarded message ----------
From: Michael S. removed_email_address@domain.invalid
Date: Oct 27, 2007 11:21 AM
Subject: Re: freeimage on leopard
To: Thomas M. removed_email_address@domain.invalid

Hi Thomas,

I have been able to successfully install FreeImage and Image_Science
but I can’t guarantee the results. In my situation, my image uploads
seem to be a bit broken. Although FreeImage and Image_Science do
install successfully as far as I can tell.

This was my stopping point last night, so I have not investigated
further. I plan to today. However, your mileage may vary.

I filed a bug report at:
http://rubyforge.org/tracker/index.php?func=detail&aid=15093&group_id=1513&atid=5921

Also these patches to ruby seem to have made it into macports already…
more info here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12895

which will give you info on why ruby segfaults etc…

I grabbed the macports source tarball and compiled it, then ran “port
selfupdate” then when I built ruby the patches were applied.

When installing the dev tools make sure to have installed 10.3.9 SDK
(it’s not selected by default)

after building ruby and rb-rubygems with macports I installed
FreeImage from source and edited the Makefile.osx but if you are using
MacPorts to install FreeImage you can go ahead and attempt to install
it or just download it and edit the Makefile.

if you attempt to install it, which is fine… it will fail with…

ld: library not found for -ldylib1.10.5.o
collect2: ld returned 1 exit status
make[1]: *** [libfreeimage-3.9.2.dylib-ppc] Error 1
make: *** [all] Error 2

cd
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_freeimage/work/FreeImage

and change this:

LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.4u.sdk

to this

LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk/usr/lib
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.4u.sdk/usr/lib

then install it again “port install FreeImage” it will install fine,
but maybe an error about cleaning up the build dir, don’t worry about
it…

You should be okay to install ruby, rb-rubygems now and image_science
etc.

which I should probably update since i have made progress since.

On 10/27/07, Thomas M. removed_email_address@domain.invalid wrote:


Thomas M.
removed_email_address@domain.invalid


Michael S.
Linux Admin/Developer
AIM: mikesteinfeld
GTALK: removed_email_address@domain.invalid


Michael S.
Linux Admin/Developer
AIM: mikesteinfeld
GTALK: removed_email_address@domain.invalid


#2

I’ve gotten pretty far with Michael’s help so far. After editing
Makefile.osx and making sure that the 10.3 developer sdk was installed
from the Leopard install disk (through xcode dev tools install) I was
able to get freeimage installed through macport as well as the image
science gem installed. Still not loading correctly though:

CompilationError (error executing cc -arch ppc -arch i386 -pipe -
bundle -I/opt/local/include -fno-common -arch ppc -arch i386 -Os -
pipe -fno-common -I /System/Library/Frameworks/Ruby.framework/Versions/
1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I /System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/include -o “/Users/
tsmango/.ruby_inline/Inline_ImageScience_aa58.bundle” “/Users/
tsmango/.ruby_inline/Inline_ImageScience_aa58.c” -L/opt/local/lib -
lfreeimage -lstdc++: 256
Renamed /Users/tsmango/.ruby_inline/Inline_ImageScience_aa58.c to /
Users/tsmango/.ruby_inline/Inline_ImageScience_aa58.c.bad):
/Library/Ruby/Gems/1.8/gems/RubyInline-3.6.4/lib/inline.rb:399:in
build' /Library/Ruby/Gems/1.8/gems/RubyInline-3.6.4/lib/inline.rb:676:ininline’
/Library/Ruby/Gems/1.8/gems/image_science-1.1.3/lib/
image_science.rb:84
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/rubygems/custom_require.rb:32:in gem_original_require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/rubygems/custom_require.rb:32:inrequire’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in require' .//app/controllers/users_controller.rb:1 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:203:inload_without_new_constant_marking’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:203:in load_file' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:202:in load_file' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:94:inrequire_or_load’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:248:in load_missing_constant' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:452:inconst_missing’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:464:in const_missing' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/inflector.rb: 250:inconstantize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/
string/inflections.rb:148:in constantize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb: 1284:inrecognize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in dispatch' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:inprocess’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in
synchronize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:inprocess’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in
process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:ineach’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in
process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:inrun’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in initialize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:innew’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:ininitialize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in new' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:inrun’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in
run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:ineach’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in
run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:inrun’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:488:inload’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:488:in load' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:488:in load' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/rubygems/custom_require.rb:27:in require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:inrequire’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:342:in new_constants_in' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:inrequire’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/rubygems/custom_require.rb:27:in gem_original_require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/rubygems/custom_require.rb:27:inrequire’
script/server:3

On Oct 27, 11:31 am, “Michael S.” removed_email_address@domain.invalid


#3

try removing ~/.ruby_inline

then try again.

On 10/27/07, Thomas M. removed_email_address@domain.invalid wrote:

1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I /System/Library/Frameworks/
/Library/Ruby/Gems/1.8/gems/image_science-1.1.3/lib/
dependencies.rb:342:in new_constants_in' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ dependencies.rb:248:inload_missing_constant’
ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/
synchronize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:innew’
run' ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
dependencies.rb:495:in `require’

---------- Forwarded message ----------
install successfully as far as I can tell.

it…

when I was searching for answers, I came across this post you made
Michael S.


Michael S.
Linux Admin/Developer
AIM: mikesteinfeld
GTALK: removed_email_address@domain.invalid


#4

Nope, same thing.


#5

Have you upgraded XCode tools from the Leopard install dvd?


#6

After reading
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12895
again, it seems to me like these patches have already been applied to
ruby in Leopard, so I did not rebuild ruby. Maybe that’s what’s going
on?


#7

Full installation instructions (full credit goes to: Michael S.
for figuring this out)

  1. I started with a clean install of Leopard.
  2. Install macports for 10.4
  3. Install the xcode dev tools from the Leopard disk - be sure to
    also install the 10.3 sdk from the xcode dev tools install
  4. sudo port install freeimage
  5. cd /opt/local/var/macports/build/
    _opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_freeimage/
    work/FreeImage

and change this:

LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.4u.sdk

to this

LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk/usr/
lib
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.4u.sdk/usr/
lib

  1. sudo port install freeimage
  2. sudo gem install -y imagescience
  3. cd /Library/Ruby/Gems/1.8/gems/RubyInline-3.6.4/lib
  4. edit inline.rb

look for the line “flags = @flags.join(’ ')”
and change it to “flags = @flags.join(’ ‘) + ’ -lruby’”

  1. remove ~/.ruby_inline

Again, many thanks to Michael for figuring this all out!


#8

Yep, Michael had me install the 10.3 sdk which made it possible for
free image to install. He then gave me final patch for ruby inline
that made everything work. I’ll post that later today.


Thomas M.
removed_email_address@domain.invalid


#9

Thanks a lot. This worked for me.

Just want to reiterate one thing about the Xcode step. You will have
to click “Customize” and then check “Mac OS X 10.3.9 Support”.


#10

FWIW, I updated the include and library references to 10.5 and removed
all PPC references (I’m on intel) to get the following makefile.
Seems to have compiled FreeImage successfully - testing it now.

Todd

-- Makefile --

Mac OSX makefile for FreeImage

This file can be generated by ./gensrclist.sh

include Makefile.srcs

General configuration variables:

CC_I386 = gcc-4.0
CPP_I386 = g+±4.0
COMPILERFLAGS = -Os
COMPILERFLAGS_I386 = -arch i386
COMPILERPPFLAGS = -Wno-ctor-dtor-privacy
INCLUDE +=
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.5.sdk/
CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $
(INCLUDE_I386)
CPPFLAGS_I386 = $(COMPILERPPFLAGS) $(CFLAGS_I386)
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk/usr/
lib
LIBTOOL = libtool
LIPO = lipo

TARGET = freeimage
STATICLIB = lib$(TARGET).a
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).dylib
LIBNAME = lib$(TARGET).$(VER_MAJOR).dylib
HEADER = Source/FreeImage.h

.SUFFIXES: .o-i386
MODULES_I386 = $(SRCS:.c=.o-i386)
MODULES_I386 := $(MODULES_I386:.cpp=.o-i386)

PREFIX = /usr/local
INSTALLDIR = $(PREFIX)/lib
INCDIR = $(PREFIX)/include

default: all

all: dist

dist: FreeImage
cp *.a Dist
cp *.dylib Dist
cp Source/FreeImage.h Dist

FreeImage: $(STATICLIB) $(SHAREDLIB)

$(STATICLIB): $(STATICLIB)-i386
$(LIPO) -create $(STATICLIB)-i386 -output $(STATICLIB)

$(STATICLIB)-i386: $(MODULES_I386)
$(LIBTOOL) -arch_only i386 -o $@ $(MODULES_I386)

$(SHAREDLIB): $(SHAREDLIB)-i386
$(LIPO) -create $(SHAREDLIB)-i386 -output $(SHAREDLIB)

$(SHAREDLIB)-i386: $(MODULES_I386)
$(CPP_I386) -arch i386 -dynamiclib $(LIBRARIES_I386) -o $@ $
(MODULES_I386)

.c.o-i386:
$(CC_I386) $(CFLAGS_I386) -c $< -o $@

.cpp.o-i386:
$(CPP_I386) $(CPPFLAGS_I386) -c $< -o $@

install:
install -d -m 755 -o root -g wheel $(INCDIR) $(INSTALLDIR)
install -m 644 -o root -g wheel $(HEADER) $(INCDIR)
install -m 644 -o root -g wheel $(SHAREDLIB) $(STATICLIB) $
(INSTALLDIR)
ranlib -sf $(INSTALLDIR)/$(STATICLIB)
ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME)

clean:
rm -f core Dist/. u2dtmp* $(MODULES_I386) $(STATICLIB) $(STATICLIB)-
i386 $(SHAREDLIB) $(SHAREDLIB)-i386

On Oct 27, 11:31 am, “Michael S.” removed_email_address@domain.invalid


#11

Nice, let me know how this works for you. I was pondering doing the
same, but since i had both SDK’s installed… *shrugs.

You’ll still need to pass -lruby to the compiler flags (if your using
apples /usr/bin/ruby and RubyInline). I wrote a sed one-liner to edit
inline.rb

sudo sed -i -e “387,1s/flags\ =\ @flags.join(’\ ‘)/&\ +\ ’
-lruby’/”
/usr/lib/ruby/user-gems/1.8/gems/RubyInline-3.6.4/lib/inline.rb

-mike