trying to install gd2-1.1.1 (and turing) in windows with rubygems - ruby 1.8.7

210 views
Skip to first unread message

Zeno R.R. Davatz

unread,
Jan 5, 2011, 10:55:01 AM1/5/11
to RubyInstaller
Hi

I am trying to install gd2 on Windows Vista via gem. What I done and
the error I get is here:

http://dev.ywesee.com/wiki.php/Gem/ChoddbWindows

I now going to try this solution:

http://rubyforge.org/tracker/index.php?func=detail&aid=3564&group_id=1103&atid=4331

installing the bdg.dll by hand.

Any hints are more then welcome.

Best
Zeno

Luis Lavena

unread,
Jan 5, 2011, 11:20:07 AM1/5/11
to rubyin...@googlegroups.com
On Wed, Jan 5, 2011 at 12:55 PM, Zeno R.R. Davatz <zda...@gmail.com> wrote:
> Hi
>
> I am trying to install gd2 on Windows Vista via gem. What I done and
> the error I get is here:
>
> http://dev.ywesee.com/wiki.php/Gem/ChoddbWindows
>
> I now going to try this solution:
>
> http://rubyforge.org/tracker/index.php?func=detail&aid=3564&group_id=1103&atid=4331
>
> installing the bdg.dll by hand.
>

My steps:

1) Downloaded libgd from their download page:

http://www.libgd.org/releases/
(http://www.libgd.org/releases/gd-latest-win32.zip)

2) Extracted GD2 into it's own folder C:\GD2

3) Added the bin directory to the PATH

SET PATH=C:\GD2\bin;%PATH%

4) Installed gd2 gem:

C:\Users\Luis>gem install gd2
Fetching: gd2-1.1.1.gem (100%)
Successfully installed gd2-1.1.1
1 gem installed

5) Attempt to use gd2 from IRB:

C:\Users\Luis>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'gd2'
RuntimeError: unknown error
from C:/Users/Luis/.gem/ruby/x86-mingw32/1.8/gems/gd2-1.1.1/lib/gd2.rb:58:in
`initialize'
from C:/Users/Luis/.gem/ruby/x86-mingw32/1.8/gems/gd2-1.1.1/lib/gd2.rb:58:in
`dlopen'
from C:/Users/Luis/.gem/ruby/x86-mingw32/1.8/gems/gd2-1.1.1/lib/gd2.rb:58
from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p330-i386-mingw32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:34:in
`gem_original_require'
from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p330-i386-mingw32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:34:in
`require'
from (irb):2

6) Hmn, error...

Let's see why:

gd2.rb, at line 58:

LIB = DL.dlopen(gd_library_name)


So is trying to load by DL the gd_library_name, let's look at
gd_library_name value is:

line 29,

def self.gd_library_name
case Config::CONFIG['arch']
when /darwin/
'libgd.2.dylib'
when /mswin32/, /cygwin/
'bgd.dll'
else
'libgd.so.2'
end
end

It is using arch to determine the OS, checking our Ruby values.

C:\Users\Luis>ruby -rrbconfig -ve "puts RbConfig::CONFIG['arch']"
ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]
i386-mingw32

Seems our mingw is not covered... let's do some small changes:

def self.gd_library_name
case RbConfig::CONFIG['host_os']
when /darwin/
'libgd.2.dylib'
when /mingw|mswin/, /cygwin/
'bgd.dll'
else
'libgd.so.2'
end
end


And trying again:

irb(main):002:0> require 'gd2'
RuntimeError: unknown symbol "gdFontCacheSetupA"

Better!, now let's see why we get unknown symbol, which lead me to
name_for_symbol, which requires similar platform changes...

But the problem is that name_for_symbol is not considering the calling
mode (stdcall versus cdecl)

Dunno if DL::Handle[] supports specifying the calling convention, but
for sure the gd2 library needs to be updated to consider mingw
platform, which seems the first blocker.

A possible replacement of gd2 gem will be gd2-ffij:

https://github.com/dark-panda/gd2-ffij

But suffers from the same mingw platform configuration issues, yet
still adding the calling convention sounds more easy.

I would suggest contact the gem Author about calling convention
methods as the library do not support them.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Zeno R.R. Davatz

unread,
Jan 5, 2011, 11:30:49 AM1/5/11
to RubyInstaller
On 5 Jan., 17:20, Luis Lavena <luislav...@gmail.com> wrote:
> On Wed, Jan 5, 2011 at 12:55 PM, Zeno R.R. Davatz <zdav...@gmail.com> wrote:
>
> > Hi
>
> > I am trying to install gd2 on Windows Vista via gem. What I done and
> > the error I get is here:
>
> >http://dev.ywesee.com/wiki.php/Gem/ChoddbWindows
>
> > I now going to try this solution:
>
> >http://rubyforge.org/tracker/index.php?func=detail&aid=3564&group_id=...
Thank you very much! I will contact the author at:

https://rubygems.org/profiles/verement

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 10, 2011, 11:10:09 AM1/10/11
to RubyInstaller
Dear Luis

On 5 Jan., 17:20, Luis Lavena <luislav...@gmail.com> wrote:

> > I am trying to install gd2 on Windows Vista via gem. What I done and
> > the error I get is here:
>
> >http://dev.ywesee.com/wiki.php/Gem/ChoddbWindows
>
> > I now going to try this solution:
>
> >http://rubyforge.org/tracker/index.php?func=detail&aid=3564&group_id=...
Any hints how I can continue with the Calling Conventions? I am still
having the same error. I did contact the author. No reply so far.

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 11, 2011, 8:46:45 AM1/11/11
to RubyInstaller
Dear Luis

On 5 Jan., 17:20, Luis Lavena <luislav...@gmail.com> wrote:

> Seems our mingw is not covered... let's do some small changes:
>
>   def self.gd_library_name
>     case RbConfig::CONFIG['host_os']
>     when /darwin/
>       'libgd.2.dylib'
>     when /mingw|mswin/, /cygwin/
>       'bgd.dll'
>     else
>       'libgd.so.2'
>     end
>   end

This actually works just fine on Windows with the above improvements.

C:\Users\zdavatz>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'gd2'
=> true
irb(main):003:0>

if you take the bdg.dll from here: http://www.boutell.com/gd/http/gdwin32.zip

Our application though is still one step short of starting up on
Windows:

C:/Ruby-1.8.6-oniguruma/lib/ruby/1.8/e2mmap.rb:51: Use Ruby 1.1
(RuntimeError)
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `gem_original_require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/1.8/matrix.rb:23
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `gem_original_require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/gems/1.8/gems/gd2-1.1.1/
lib/gd2/canvas.rb:23
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `gem_original_require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require'
... 41 levels...
from C:/Ruby-1.8.6-oniguruma/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require'
from C:/Ruby-1.8.6-oniguruma/lib/ruby/gems/1.8/gems/
de.oddb-2.0.0/bin/oddbd:11
from C:/Ruby-1.8.6-oniguruma/bin/oddbd:19:in `load'
from C:/Ruby-1.8.6-oniguruma/bin/oddbd:19

Best
Zeno

Luis Lavena

unread,
Jan 11, 2011, 8:50:42 AM1/11/11
to rubyin...@googlegroups.com
On Tue, Jan 11, 2011 at 10:46 AM, Zeno R.R. Davatz <zda...@gmail.com> wrote:
> Dear Luis

>
>
> This actually works just fine on Windows with the above improvements.
>
> C:\Users\zdavatz>irb
> irb(main):001:0> require 'rubygems'
> => true
> irb(main):002:0> require 'gd2'
> => true
> irb(main):003:0>
>
> if you take the bdg.dll from here: http://www.boutell.com/gd/http/gdwin32.zip
>
> Our application though is still one step short of starting up on
> Windows:
>

As mentioned before, I can't change every single library to make it
work. RubyInstaller shifted from mswin to mingw, but the calling
convention should be the same.

Now is up to the gem author fix that.

Even if we modify, is up to the gem author to provide a new release.
Forking is great for development, but gem forking is bad for
community.

Can't help you beyond the help already provided. Is up to you know
understand what the gem is doing.

(and is a good practice too, since using libraries without digging
into them may lead to weird results unknown to you)

Zeno R.R. Davatz

unread,
Jan 11, 2011, 9:17:08 AM1/11/11
to RubyInstaller
On 11 Jan., 14:50, Luis Lavena <luislav...@gmail.com> wrote:
> On Tue, Jan 11, 2011 at 10:46 AM, Zeno R.R. Davatz <zdav...@gmail.com> wrote:
> > This actually works just fine on Windows with the above improvements.
>
> > C:\Users\zdavatz>irb
> > irb(main):001:0> require 'rubygems'
> > => true
> > irb(main):002:0> require 'gd2'
> > => true
> > irb(main):003:0>
>
> > if you take the bdg.dll from here:http://www.boutell.com/gd/http/gdwin32.zip
>
> > Our application though is still one step short of starting up on
> > Windows:
>
> As mentioned before, I can't change every single library to make it
> work. RubyInstaller shifted from mswin to mingw, but the calling
> convention should be the same.
>
> Now is up to the gem author fix that.
>
> Even if we modify, is up to the gem author to provide a new release.
> Forking is great for development, but gem forking is bad for
> community.
>
> Can't help you beyond the help already provided. Is up to you know
> understand what the gem is doing.
>
> (and is a good practice too, since using libraries without digging
> into them may lead to weird results unknown to you)

Ok, will try to contact the author again.

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 11, 2011, 10:14:48 AM1/11/11
to RubyInstaller
Ok, so I notified the author.

http://url.ba/1tpu

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 12, 2011, 4:24:07 AM1/12/11
to RubyInstaller
Dear Luis

I am continuing the gd2 issues as there still seems to be some
problems:

http://www.ruby-forum.com/topic/856883#974181

this works

C:\Users\zdavatz>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'gd2'
=> true

but when I start-up my application I get

lib/ruby/1.8/e2mmap.rb:51: Use Ruby 1.1 (RuntimeError)

It seems that

lib/ruby/gems/1.8/gems/gd2-1.1.1/lib/gd2/canvas.rb:23

requires

lib/ruby/1.8/matrix.rb:23

and that calls

require "e2mmap.rb"

and that will throw the error

lib/ruby/1.8/e2mmap.rb:51: Use Ruby 1.1 (RuntimeError)

is this a gd2 issue? Does gd2 somehow call the wrong version of Ruby?

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 12, 2011, 4:30:18 AM1/12/11
to RubyInstaller
seems to be connected to: http://redmine.ruby-lang.org/issues/show/4156

yep. solved.

Best
Zeno

Zeno R.R. Davatz

unread,
Jan 16, 2011, 6:10:59 AM1/16/11
to RubyInstaller
The patch is out, thanks to Jonas Tingeborn!

http://url.ba/ypi7

Best
Zeno
Reply all
Reply to author
Forward
0 new messages