cygwin problem: Could not open library 'libgeom.dll'

60 views
Skip to first unread message

Michael Jørgensen

unread,
Aug 24, 2014, 4:27:36 AM8/24/14
to ruby...@googlegroups.com
Hi,

I'm writing a small cross-platform C-library to do geometric calculations (because it is approx five times faster than in ruby).

It works fine, when running on Linux (Fedora 20), but fails when running on Windows 8 with Cygwin with the following error:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.3-x86-mingw32/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open library 'libgeom': x▒K. (LoadError)
Could not open library 'libgeom.dll':L
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.3-x86-mingw32/lib/ffi/library.rb:100:in `map'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.3-x86-mingw32/lib/ffi/library.rb:100:in `ffi_lib'
        from C:/rubytest/geom.rb:6:in `<module:Geom>'
        from C:/rubytest/geom.rb:1:in `<top (required)>'
        from main.rb:2:in `require_relative'
        from main.rb:2:in `<main>'

So in the file geom.rb I have the following:
    extend FFI::Library
    ffi_lib "libgeom"
On Linux I have the file libgeom.so and on Windows I have the file libgeom.dll

I'm using 64-bit cygwin and compiling the shared library with the following command:
    gcc -Wall -shared geom.c -o libgeom.dll

I'm using ruby 1.9.3

I've tried supplying a full path name to the dll, but that did not make a difference. I've tried adding the current directory to PATH, but still no luck.

The .dll library is completely self-contained, and requires no other libraries. (not even -lm).

I'm quite new to ruby, but was very happy with the immediate success on my Linux machine. Now I just need to get it working on Windows too.

Any ideas on a work-around?

Sincerely,
Michael.

Charles Oliver Nutter

unread,
Aug 25, 2014, 10:34:48 AM8/25/14
to Michael Jørgensen, ruby...@googlegroups.com
Are you certain the Ruby you're using is also 64-bit?

- Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "ruby-ffi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ruby-ffi+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ruby-ffi.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ruby-ffi/94524408-4ebd-4a7c-856e-a5a17f5a427b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Michael Jørgensen

unread,
Aug 25, 2014, 3:42:26 PM8/25/14
to Charles Oliver Nutter, ruby...@googlegroups.com
Ahh!

You are right, Charles. I'm combining 32-bit ruby with 64-bit Cygwin. That is why it's not working. I've removed Cygwin, and changed to 32-bit Cygwin. And now it works!

Thanks,
-Michael.

Charles Oliver Nutter

unread,
Aug 25, 2014, 3:59:02 PM8/25/14
to Michael Jørgensen, ruby...@googlegroups.com
Ok great!

I wish we had a better way to indicate this, but I don't know enough
native voodoo to tell when we're loading a 64-bit library into a
32-bit process.

- Charlie
Reply all
Reply to author
Forward
0 new messages