chipmunk-rb / chipmunk-ffi

chipmunk ruby bindings using ffi
26 stars 6 forks source link

Could not load chipmunk. (LoadError) #4

Closed utgarda closed 14 years ago

utgarda commented 14 years ago

Next one, guess it's not a bug too, more like I could use a hint.

Seems like nice-ffi doesn't work for me. I've put libchipmunk.so to all the locations it's supposed to search, like /usr/lib/libchipmunk.so, but still I was getting an error:

(in /home/etsvigun/devenv/ruby/chipmunk-ffi)
/usr/lib64/ruby/gems/1.8/gems/nice-ffi-0.3/lib/nice-ffi/library.rb:98:in `load_library': Could not load chipmunk. (LoadError) from /home/etsvigun/devenv/ruby/myforks/chipmunk-ffi/lib/chipmunk-ffi.rb:18

I remember, it did work not so long ago. Now the only way I can load the library is to provide the full path to the library ( with 5dd71a2bd93d015e4c63525fa6ad8202707d932e/lib/chipmunk-ffi.rb) :

irb -rubygems irb(main):001:0> ::CP_EXACT_PATH="./libchipmunk.so.5.1" => "./libchipmunk.so.5.1" irb(main):002:0> require 'chipmunk-ffi' => true

Did you consider adding an option to provide the exact location of chipmunk library, or do you think it's a dirty hack?

shawn42 commented 14 years ago

I think you need to look at specifying CP::LOAD_PATHS. nice-ffi sets up a few default locations to look, but it must not include your library's location. Take a look in chipmunk-ffi.rb Let me know if that helps.

shawn42 commented 14 years ago

By the way, what project are you using chipmunk-ffi for?

utgarda commented 14 years ago

Yep, I saw the default library search locations of nice-ffi, and filenames patterns it looks for, put the library to all of them. It worked before. Don't know why it's not found now. (Guess I shouldn't be lazy and try harder, put in some debug logging or smth) Also, I did add "." to the default search path of nice-ffi before saying " require 'chipmunk-ffi' ", made sure it contains "." , but - all the same - it didn't find the file in the current directory.

utgarda commented 14 years ago

About my project - about 5 years ago I used some physics engine to simulate different stuff related to organic chemistry - like chain polymerization reactions. It was the coolest thing I ever did. But back then I used msft .net and directX, and it was totally unportable. And I kept all that stuff in my local filesystems and lost it. Now I saw the light, not just trust in the opensource, but try to participate - so I'm going to reimplement that with a wiser choice of technologies. But I'm just studying ruby, so, as something to start with, I'm going to port chipmunk's examples written in c to ruby with chipmunk-ffi, maybe using ruby-processing (jashkenas@7ae50905a6ea45c385748b0805ea1832e0e9c9ab) for visualization.

shawn42 commented 14 years ago

Wow, that sounds great! Please post your project on github and let me know how it goes. I'll offer any help that I can via chipmunk-ffi.

utgarda commented 14 years ago

Seems like it was magically fixed by itself - really can't figure out what was the exact problem, but I'm happy. Btw, I've put the first translated example file : utgarda@4637d38aa8611610f6d2daf186644cb757de72c7 - does nothing but checks Space.update , nothing seen, visualization's coming soon.

utgarda commented 14 years ago

Wow, didn't I press 'Comment and Close' last time?

shawn42 commented 14 years ago

closed.