ruby-leveldb-native icon indicating copy to clipboard operation
ruby-leveldb-native copied to clipboard

"The specified module could not be found" error after install

Open ncsibra opened this issue 10 years ago • 13 comments

Hi,

I'm working on a Win7 64bit machine, compiled a leveldb.dll with mingw based on this repo: https://github.com/zalanyib/leveldb-mingw Then installed your gem, withour errors, the 'leveldb_native.so' file was created and copied to the extension directory. The problem is, when I try to require it in a script, I got an error:

G:/apps/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': 126: The specified module could not be found.   - G:/apps/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/leveldb-native-0.6/leveldb-native/leveldb_native.so (LoadError)
    from G:/apps/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from G:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/leveldb-native-0.6/lib/leveldb-native.rb:1:in `<top (required)>'
    from G:/apps/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in `require'
    from G:/apps/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from G:/apps/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:144:in `require'
    from G:/home/dev/dbtest/test.rb:2:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

As I see from google searches, it doesn't find the dll file. I tried severeal things:

  • add the location of the dll to the PATH
  • copy to the ruby bin and lib directory
  • copy to a directory which in the LOAD_PATH
  • do all of the previous with file names 'leveldb.dll' and 'libleveldb.dll' None of them helped.

How can I solve this? Where it search for the DLL and which name?

ncsibra avatar May 03 '14 13:05 ncsibra

This is fixed by your patch, right?

vjoel avatar May 03 '14 17:05 vjoel

No, that just helped to compile without Makefile hack. I figured out one thing since, if I copy the 'leveldb.dll' to ruby bin dir and run the sample script from 'Synopsis' in a mingw terminal, then it works, but it doesn't from the windows command line, nor from RubyMine. Is it mean that the 'leveldb-mingw' project compiled a dll which not useable from normal windows environment?

I never used native extensions before and not compile stuff myself to much, therefore I don't really know how this linking works, but I compiled a C++ api earlier in mingw, which created an .so and .rb file and that worked fine outside of mingw with Ruby. Do you used it on windows?

ncsibra avatar May 03 '14 18:05 ncsibra

Sorry, no, I haven't used it on windows.

When you built leveldb (the C++ lib, I mean, not the ruby extension), did you make install? Where did that put the dll files?

One thing you might try in mingw: Go into dir where the installed gem keeps the dll/so file, which should be some dir like

/usr/local/lib/ruby/gems/2.1.0/gems/leveldb-native-0.6/lib/leveldb-native

and type

ldd leveldb_native.so

(or .dll, I forget which it is on mingw). On my linux system, the output is

libleveldb.so.1 => /usr/local/lib/libleveldb.so.1 (0xb6f4a000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6f27000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6e7f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6d9c000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6d7a000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d0f000)
/lib/ld-linux-armhf.so.3 (0xb6f8d000)

The first line above tells you where the gem's dll is looking for the leveldb dll. If this doesn't match up to the location of leveldb's dll, that would cause an error.

vjoel avatar May 03 '14 18:05 vjoel

There is no ldd in mingw, but I used this: objdump.exe -p leveldb_native.so | grep 'DLL Name:' Output:

DLL Name: leveldb.dll
DLL Name: kernel32.dll
DLL Name: msvcrt.dll
DLL Name: libgcc_s_dw2-1.dll
DLL Name: libstdc++-6.dll
DLL Name: msvcrt-ruby191.dll

Then ran this software: http://dependencywalker.com/ and it's showed the that libstdc++-6.dll and libgcc_s_dw2-1.dll is missing, after copied them to ruby bin, works from everywhere.

Thanks for your help, now just need to figure out how to put all of this together in a gem to easily install on any windows machine, because really sucks this way. :)

ncsibra avatar May 03 '14 18:05 ncsibra

If the missing part is libstdc++, then maybe some of the ruby/windows experts can help. Luis Lavena, maybe.

Or maybe there is some other gem that uses c++ on mingw and that builds and installs correctly. Might be some idea there we could adapt.

vjoel avatar May 03 '14 19:05 vjoel

Sorry, copy-paste error, libgcc_s_dw2-1.dll missed too, corrected previous post. I'm checking other alternatives too, but there is not too much embedded nosql db, which has a windows binary and a correct ruby wrapper. Similar is ejdb, but as I see that requires the same method to build like your gem. I though about a rake task to do all the hard work, but your recommended person wrote a tool which looks promising. :)

ncsibra avatar May 03 '14 19:05 ncsibra

What about other gems that are based on c++ but not db related?

This seems to be a very similar problem:

http://stackoverflow.com/questions/8318299/eventmachine-gem-workaround-causes-missing-dll-file-ruby-error-windows-7

vjoel avatar May 03 '14 22:05 vjoel

It's basically says that running native extensions in windows is sucks, use linux, if not then add the devkit to your path, which is a solution if the machine has devkit, but I don't want to force anybody to install that, I want an out of the box solution. I tried gem compiler, runs fine, but don't add anything to the newly built gem, just remove the extension section from the metadata, so basically doesn't do anything in windows.

ncsibra avatar May 04 '14 08:05 ncsibra

Do any of the other leveldb gems work on your system? IIRC, ruby-leveldb builds the C++ leveldb code as part of the gem. There is another one that uses FFI.

vjoel avatar May 04 '14 16:05 vjoel

DAddYE version requires 2.0.0 ruby, I using 1.9.3, the ruby-leveldb is 2 years old and you wrote that 'No snapshots', which not necessary now, but maybe will later, so I don't even tried it, but maybe will or at least stole how it's built the code. :) I will think about what is the best and easiest option for my requirerments. Thanks again for your help!

ncsibra avatar May 04 '14 17:05 ncsibra

HI,

Just one extra question, maybe that's the easiest way to ask. The iterator.rb and the test-iterator.rb scripts runs fine for you on linux? It looks the code in the ruby file runs fine, but after that something happening in the C++ code, because I'm getting this error:

Assertion failed: dummy_versions_.next_ == &dummy_versions_, file db/version_set.cc, line 803 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

It throws for after 'iterator' method call. Didn't you experienced similar problem?

ncsibra avatar May 06 '14 17:05 ncsibra

On 05/06/2014 10:00 AM, Norbert Csibra wrote:

HI,

Just one extra question, maybe that's the easiest way to ask. The iterator.rb and the test-iterator.rb scripts runs fine for you on linux? It looks the code in the ruby file runs fine, but after that something happening in the C++ code, because I'm getting this error:

Assertion failed: dummy_versions_.next_ == &dummy_versions_, file db/version_set.cc, line 803 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

Didn't you experienced similar problem?

— Reply to this email directly or view it on GitHub https://github.com/vjoel/ruby-leveldb-native/issues/4#issuecomment-42329326.

For me, on linux, both of these files (example/iterator.rb and test/test-iterator.rb) run without error.

What version of leveldb are you using? I'm using this:

https://github.com/vjoel/leveldb

which is based on the official 1.14 release plus a minor addition to the makefile.

vjoel avatar May 06 '14 17:05 vjoel

I'm using this: https://github.com/zalanyib/leveldb-mingw Which is based on the 1.15 release. I saw your version, but that's doesn't work on Windows.

ncsibra avatar May 06 '14 17:05 ncsibra