Unable to load/use the Ruby/GD2 module version 1.1.1 with bgd.dll v2.0.34 on the Windows platform for the following
reason:
The module doesn't generate the correct function name in GD2#name_for_symbol() [line 40 in gd2.rb] for Windows when
using version 2.0.34 of bgd.dll (downloaded from: http://www.libgd.org/releases/oldreleases/gd-2.0.34-win32.zip
on 2008-05-30).
This version of bgd.dll uses the __stdcall calling convention and the GD2#name_for_symbol method correctly adds the
suffix for Windows: 'gdImageCreate' becomes 'gdImageCreate@8'. However, after inspecting the exported functions in bgd.dll
(http://www.dependencywalker.com/ works great on windows for inspecting this) the functions ALSO need an underscore
prefix (standard __stdcall name mangling done by MS Visual Studio): "_gdImageCreate@8".
However, apparently, the following functions are explicitly exported since they have neither the prefix or suffix:
gdFontGiant
gdFontLarge
gdFontMediumBold
gdFontSmall
gdFontTiny
Because of the incorrect names, the RuntimeError happens when building the GD2#SYM hash with the inject() method when
GD2#LIB's square-bracket operator '[]' is used, in the DL::Handle#[func, prototype] method (where DL#name_for_symbol()
gets called). [line 150 in gd2.rb].
The obvious fix (may break users with older bgd.dll versions, I don't know) is to update the GD2#name_for_symbol()
method.
Example GD2#name_for_symbol():
def self.name_for_symbol(symbol, signature)
undecordated = ['gdFontGiant', 'gdFontLarge', 'gdFontMediumBold', 'gdFontSmall', 'gdFontTiny']
case
when Config::CONFIG['arch'] =~ /mswin32|cygwin/ && !undecordated.include?(symbol)
sum = -4
signature.each_byte do |char|
sum += case char
when ?D: 8
else 4
end
end
"_#{symbol}@#{sum}"
else
symbol.to_s
end
end
With the above implementation (added 1 line, changed 3) it doesn't die when I do a "require 'gd2'". However,
I haven't done any testing for other problems.
|