Quick rubyinline fix for leopard (image_science) Undefined symbols issue

if you install the RubyInline gem and image_science and are having
problems…

remove your .ruby_inline directory and run this sed one-liner.

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

for more info on this issue see:

http://trac.macosforge.org/projects/ruby/wiki/Troubleshooting


Michael S.
Linux Admin/Developer
AIM: mikesteinfeld
GTALK: [email protected]

Hello Michael,

I am trying to get image_science working on leopard and have a problem
with the no symbols error you mentioned. I don’t have much experience
with make files so excuse any obvious errors =)

  1. Installed rubyinline

  2. updated the flags as per the macosforge wiki entry
    flags = @flags.join(’ ‘) >> flags = @flags.join(’ ‘) + ’ -lruby’

  3. Updated the Makefile.osx removing references to ppc, note im not
    appending /usr/lib to the SDK path (see below)

  4. make + make installed + required with the results below.

== Running make results in this error towards the end of the log ==

libtool: file: ./Source/FreeImage/FreeImageC.o-i386 has no symbols
libtool: file: Source/LibJPEG/jfdctflt.o-i386 has no symbols
libtool: file: Source/LibJPEG/jidctflt.o-i386 has no symbols
libtool: file: Source/LibJPEG/jquant1.o-i386 has no symbols
libtool: file: Source/LibJPEG/jquant2.o-i386 has no symbols
libtool: file: Source/LibMNG/libmng_chunk_xs.o-i386 has no symbols
libtool: file: Source/LibMNG/libmng_trace.o-i386 has no symbols
libtool: file: Source/LibPNG/pnggccrd.o-i386 has no symbols
libtool: file: Source/LibPNG/pngvcrd.o-i386 has no symbols
lipo -create libfreeimage.a-i386 -output libfreeimage.a

== Error from sudo make install ==

make -f Makefile.osx install
install -d -m 755 -o root -g wheel /usr/local/include /usr/local/lib
install -m 644 -o root -g wheel Source/FreeImage.h /usr/local/include
install -m 644 -o root -g wheel libfreeimage-3.9.3.dylib libfreeimage.a 
/usr/local/lib
ranlib -sf /usr/local/lib/libfreeimage.a
ranlib: file: /usr/local/lib/libfreeimage.a(FreeImageC.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(jfdctflt.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(jidctflt.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(jquant1.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(jquant2.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(libmng_chunk_xs.o-i386) has 
no symbols
ranlib: file: /usr/local/lib/libfreeimage.a(libmng_trace.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(pnggccrd.o-i386) has no 
symbols
ranlib: file: /usr/local/lib/libfreeimage.a(pngvcrd.o-i386) has no 
symbols
ln -sf libfreeimage-3.9.3.dylib /usr/local/lib/libfreeimage.3.dylib

== Error from requiring ‘image_science’ ==

require 'image_science'
ld: warning in /usr/local/lib/libfreeimage.a, file is not of required 
architecture
Undefined symbols for architecture ppc:
  "_FreeImage_Copy", referenced from:
      _with_crop in ccDZUv7q.o
  "_FreeImage_GetWidth", referenced from:
      _width in ccDZUv7q.o
  "_FreeImage_Unload", referenced from:
      _unload in ccDZUv7q.o
  "_FreeImage_FIFSupportsReading", referenced from:
      _with_image in ccDZUv7q.o
  "_FreeImage_GetFileType", referenced from:
      _with_image in ccDZUv7q.o
  "_FreeImage_GetICCProfile", referenced from:
      _copy_icc_profile in ccDZUv7q.o
  "_FreeImage_GetFormatFromFIF", referenced from:
      _FreeImageErrorHandler in ccDZUv7q.o
  "_FreeImage_GetFIFFromFilename", referenced from:
      _with_image in ccDZUv7q.o
      _save in ccDZUv7q.o
  "_FreeImage_Load", referenced from:
      _with_image in ccDZUv7q.o
  "_FreeImage_Rescale", referenced from:
      _resize in ccDZUv7q.o
  "_FreeImage_CreateICCProfile", referenced from:
      _copy_icc_profile in ccDZUv7q.o
  "_FreeImage_DestroyICCProfile", referenced from:
      _save in ccDZUv7q.o
  "_FreeImage_Save", referenced from:
      _save in ccDZUv7q.o
  "_FreeImage_FIFSupportsWriting", referenced from:
      _save in ccDZUv7q.o
  "_FreeImage_FIFSupportsICCProfiles", referenced from:
      _copy_icc_profile in ccDZUv7q.o
  "_FreeImage_GetHeight", referenced from:
      _height in ccDZUv7q.o
  "_FreeImage_SetOutputMessage", referenced from:
      _Init_Inline_ImageScience_aa58 in ccDZUv7q.o
ld: symbol(s) not found for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: 
/var/folders/Dm/DmFj1CSFFaymiUXshh6BHU+++TI/-Tmp-//cccTTNtd.out (No such 
file or directory)
CompilationError: error executing cc -arch ppc -arch i386 -pipe -bundle 
-lruby  -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/adam/.ruby_inline/Inline_ImageScience_aa58.bundle" 
"/Users/adam/.ruby_inline/Inline_ImageScience_aa58.c" -lfreeimage 
-lstdc++: 256
Renamed /Users/adam/.ruby_inline/Inline_ImageScience_aa58.c to 
/Users/adam/.ruby_inline/Inline_ImageScience_aa58.c.bad
  from /Library/Ruby/Gems/1.8/gems/RubyInline-3.6.4/lib/inline.rb:399:in 
`build'
  from /Library/Ruby/Gems/1.8/gems/RubyInline-3.6.4/lib/inline.rb:676:in 
`inline'
  from 
/Library/Ruby/Gems/1.8/gems/image_science-1.1.3/lib/image_science.rb:84
  from 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in 
`gem_original_require'
  from 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in 
`require'
  from (irb):1

== Edited makefile ==

# -*- 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
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


I have been able to install image_science on leopard. I could not get
the modified intel make file to work so instead installed the 10.3.9 sdk
and appended /usr/lib to the libraries_* vars.
Cheers for paving the way Micheal.

Has anyone been able to install freeimage on leopard?