Forums Archived

The forums are being archived. See this topic for more information.

*sigh* Hating on Windows and Rubygame now

Get help and support with Rubygame

*sigh* Hating on Windows and Rubygame now

Postby cgmjr » Sat Mar 06, 2010 3:04 pm

I had to install a "real" version of Windows 7. My dev work is on a separate drive altogether, so I didn't touch that. Everything was working fine prior to the Win7 reinstall. Now, I got buttkus, and a demo looming next week :(

Apparently my rubygame install is broken. I've completely uninstalled rubygame, and reinstalled per instructions, even the "gem install ffi --version "<0.6" maneuver. I get this in irb:

Code: Select all
D:\>irb
irb(main):001:0> require 'rubygame'
LoadError: Could not load SDL.
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/nice-ffi-0.3/lib/nice-ffi/librar
y.rb:98:in `load_library'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-sdl-ffi-0.2/lib/ruby-sdl-ff
i/sdl.rb:47:in `<module:SDL>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-sdl-ffi-0.2/lib/ruby-sdl-ff
i/sdl.rb:34:in `<top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame/main
.rb:22:in `require'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame/main
.rb:22:in `<top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:4
4:in `require'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:4
4:in `block in <top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:2
9:in `each'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:2
9:in `<top (required)>'
        from (irb):1:in `require'
        from (irb):1
        from D:/Ruby19/bin/irb:12:in `<main>'
irb(main):002:0> quit

D:\>gem list

*** LOCAL GEMS ***

archive-tar-minitar (0.5.2)
columnize (0.3.1)
ffi (0.6.2, 0.5.4)
linecache19 (0.5.11)
nice-ffi (0.3)
ocra (1.1.3)
rake (0.8.7)
ruby-debug-base19 (0.11.23)
ruby-debug-ide (0.4.9)
ruby-sdl-ffi (0.2)
ruby_core_source (0.1.4)
rubygame (2.6.2)
test-unit (2.0.6)

D:\>


I have confirmed that all of the SDL dlls are in c:\windows\system32. I can't see what is amiss.

Any ideas, suggestions?
User avatar
cgmjr
 
Posts: 39
Joined: Mon Jan 11, 2010 6:41 am

Re: *sigh* Hating on Windows and Rubygame now

Postby cyplo » Sun Mar 07, 2010 7:34 pm

same here, no ideas on solving
cyplo
 
Posts: 2
Joined: Sun Mar 07, 2010 7:34 pm

Re: *sigh* Hating on Windows and Rubygame now

Postby jacius » Wed Mar 10, 2010 4:56 am

This is probably related to a stupid bug in Nice-FFI -- it's not expanding the *'s like I meant it to. I really ought to test this code better. :?

Please try this fix:

  • Find the location where the nice-ffi gem is installed. It's probably in a subdirectory of your main ruby installation, but I'm not really familiar with gem installation paths on Windows.
  • Find the "pathset.rb" file, and open it up in an editor.
  • Change line 469 from this:
    Code: Select all
    File.expand_path( File.join(path,file).gsub("[NAME]",name) )
    to this:
    Code: Select all
    Dir[ File.expand_path( File.join(path,file).gsub("[NAME]",name) ) ]
That should be it. If you have trouble finding the files or something, let me know and I'll package up a gem to tide you over until I release a bugfix version.

If the above doesn't help, let me know, as there's probably yet another bug lurking around. :roll:
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Re: *sigh* Hating on Windows and Rubygame now

Postby cgmjr » Wed Mar 10, 2010 6:54 am

No joy, jacius; after the change you suggested I still get this. Note that I did a dir to show that the SDL*.dlls are there:

Code: Select all
C:\Users\Gary>irb
irb(main):001:0> require 'rubygame'
LoadError: Could not load SDL.
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/nice-ffi-0.3/lib/nice-ffi/library.rb:98:in `load_library'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-sdl-ffi-0.2/lib/ruby-sdl-ffi/sdl.rb:47:in `<module:SDL>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-sdl-ffi-0.2/lib/ruby-sdl-ffi/sdl.rb:34:in `<top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame/main.rb:22:in `require'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame/main.rb:22:in `<top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:44:in `require'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:44:in `block in <top (required)>'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:29:in `each'
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/rubygame-2.6.2/lib/rubygame.rb:29:in `<top (required)>'
        from (irb):1:in `require'
        from (irb):1
        from D:/Ruby19/bin/irb:12:in `<main>'
irb(main):002:0> exit

C:\Users\Gary>dir \windows\system32\sdl*.*
Volume in drive C has no label.
Volume Serial Number is 240E-1837

Directory of C:\windows\system32

03/05/2010  09:08 PM           324,096 SDL.dll
03/05/2010  09:05 PM            62,464 SDL_gfx.dll
03/05/2010  09:06 PM            43,520 SDL_image.dll
03/05/2010  09:07 PM           143,872 SDL_mixer.dll
03/05/2010  09:30 PM            19,456 SDL_ttf.dll
               5 File(s)        593,408 bytes
               0 Dir(s)  450,295,611,392 bytes free

C:\Users\Gary>


One oddity to report: my pathset.rb had a different line 469 than what you said. Mine has:
Code: Select all
File.expand_path( (path+file).gsub("[NAME]", name) )
User avatar
cgmjr
 
Posts: 39
Joined: Mon Jan 11, 2010 6:41 am

Re: *sigh* Hating on Windows and Rubygame now

Postby cgmjr » Wed Mar 10, 2010 7:29 am

I've fired up my debugger, and I am suspicious of the code in module FFI::Library.

Everything seems to be working as intended until line 10 in method ffi_lib(*names):

Code: Select all
4  def ffi_lib(*names)
5   ffi_libs = []
6   errors = {}
7   names.each do |name|
8     [ name, FFI.map_library_name(name) ].each do |libname|
9       begin
10        lib = FFI::DynamicLibrary.open(libname, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL)
11        if lib
12          ffi_libs << lib
13          break
14        end
15      rescue Exception => ex
16        errors[name] = ex
17      end
18    end
19  end
20  if ffi_libs.empty?
21    msgs = []
22    errors.each {|name, ex| msgs << "Failed to load library '#{name}': #{ex.message}" }
23    raise LoadError.new(msgs.join('\n'))
24  end
25
26  @ffi_libs = ffi_libs
27 end


The value of name in the block is "SDL", and on the 1st pass the value in libname is also just "SDL". The value of lib remains nil after the call to FFI::DynamicLibrary.open(), and then we jump to the rescue block. A second loop occurs, name="SDL" and this time libname="SDL.dll". But, lib is still nil at the end of the 2nd loop, and so is ffi_libs and we raise a LoadError.new(msgs.join('\n')) at line 23.

I hope that helps,
g.
User avatar
cgmjr
 
Posts: 39
Joined: Mon Jan 11, 2010 6:41 am

Re: *sigh* Hating on Windows and Rubygame now

Postby jacius » Wed Mar 10, 2010 9:51 am

cgmjr wrote:One oddity to report: my pathset.rb had a different line 469 than what you said. Mine has:
Code: Select all
File.expand_path( (path+file).gsub("[NAME]", name) )

Ah, sorry, I forgot that I had already changed that line to do File.join, in the time since the last release. But if you either wrapped "Dir[ ... ]" around your line or pasted in mine, it should have fixed the bug I mentioned. So perhaps that's not the problem. But if it was fixed, I would have expected it to try loading "C:\\windows\\system32\\SDL.dll" before trying "SDL"...

Could you try these snippets (separately), and see what error messages they give you? They may be more informative than the generic message Nice-FFI produces.

Code: Select all
require 'ffi'
module SDL
  extend FFI::Library
  ffi_lib "SDL"
end

Code: Select all
require 'ffi'
module SDL
  extend FFI::Library
  ffi_lib "C:\\windows\\system32\\SDL.dll"
end
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Re: *sigh* Hating on Windows and Rubygame now

Postby cgmjr » Wed Mar 10, 2010 3:16 pm

My results:

Code: Select all
C:\Users\Gary>irb
irb(main):001:0> require 'ffi'
=> true
irb(main):002:0> module SDL
irb(main):003:1> extend FFI::Library
irb(main):004:1> ffi_lib "SDL"
irb(main):005:1> end
LoadError: Failed to load library 'SDL': Could not open library 'SDL.dll': The specified module could not be found.
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ffi-0.5.4-x86-mingw32/lib/ffi/library.rb:23:in `ffi_lib'
        from (irb):4:in `<module:SDL>'
        from (irb):2
        from D:/Ruby19/bin/irb:12:in `<main>'
irb(main):006:0>



Code: Select all
C:\Users\Gary>irb
irb(main):001:0> require 'ffi'
=> true
irb(main):002:0> module SDL
irb(main):003:1> extend FFI::Library
irb(main):004:1> ffi_lib "C:\\windows\\system32\\SDL.dll"
irb(main):005:1> end
LoadError: Failed to load library 'C:\windows\system32\SDL.dll': Could not open
library 'C:\windows\system32\SDL.dll': The specified module could not be found.
        from D:/Ruby19/lib/ruby/gems/1.9.1/gems/ffi-0.5.4-x86-mingw32/lib/ffi/library.rb:23:in `ffi_lib'
        from (irb):4:in `<module:SDL>'
        from (irb):2
        from D:/Ruby19/bin/irb:12:in `<main>'
irb(main):006:0> exit

C:\Users\Gary>dir C:\windows\system32\SDL.dll
Volume in drive C has no label.
Volume Serial Number is 240E-1837

Directory of C:\windows\system32

03/05/2010  09:08 PM           324,096 SDL.dll
               1 File(s)        324,096 bytes
               0 Dir(s)  449,406,959,616 bytes free

C:\Users\Gary>
User avatar
cgmjr
 
Posts: 39
Joined: Mon Jan 11, 2010 6:41 am

Re: *sigh* Hating on Windows and Rubygame now

Postby jacius » Wed Mar 10, 2010 10:07 pm

Ah, cfaftw just posted this in another thread, which might help if you are using 64-bit Win7. Apparently 32-bit libraries are supposed to go in "C:\windows\syswow64\" instead of "C:\windows\system32". So confusing! Gotta love Microsoft. :roll:
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Re: *sigh* Hating on Windows and Rubygame now

Postby brandon » Wed Mar 10, 2010 10:10 pm

I avoid these snafus by putting my development binares in a separate directory, and then add that directory to my PATH environment variable. It's a lot less confusing, and it keeps clutter out of the windows system folder.
brandon
 
Posts: 9
Joined: Wed Mar 10, 2010 7:07 pm

Re: *sigh* Hating on Windows and Rubygame now

Postby cgmjr » Sun Mar 28, 2010 6:33 pm

Hello Rubygamers. Quick update: I confirm that putting those SDL dlls, and their supporting dlls such as jpeg.dll et al, will indeed fix this problem.

Moving on now to fun with Sprites and Hotspots.
User avatar
cgmjr
 
Posts: 39
Joined: Mon Jan 11, 2010 6:41 am


Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron