Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load librocksdbjni-win64.dll in windows10 #2531

Closed
ashkrit opened this issue Jul 2, 2017 · 27 comments
Closed

Unable to load librocksdbjni-win64.dll in windows10 #2531

ashkrit opened this issue Jul 2, 2017 · 27 comments
Assignees

Comments

@ashkrit
Copy link

ashkrit commented Jul 2, 2017

I am using 5.4.5 version or rocksdb on windows 10 https://mvnrepository.com/artifact/org.rocksdb/rocksdbjni/5.4.5

It fails with below error:

Exception in thread "main" java.lang.UnsatisfiedLinkError:c:\XXX\librocksdbjni-win64.dll: A dynamic link library (DLL) initialization routine failed
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
	at java.lang.Runtime.load0(Runtime.java:809)

Has anybody faced similar issue on windows ?

@adamretter
Copy link
Collaborator

adamretter commented Jul 5, 2017

@ashkrit The file librocksdbjni-win64.dll is included within the Jar file. We need to understand why it won't load on your system, perhaps some missing dependency that you need to install. You could try extracting the .dll from the Jar, placing it in a known path and using a small Java program to try and load it to see if you can get more detailed error messages:

public class LoadTest {
  public static void main(final String args[]) {
    System.loadLibrary("librocksdbjni-win64");
  }
}

Then to compile and run it:

javac LoadTest.java
java -classpath . -Djava.library.path=C:\dir-containing-rocksdb-dll LoadTest

@adamretter adamretter self-assigned this Jul 5, 2017
@qzo
Copy link

qzo commented Aug 12, 2017

I can confirm the issue. Everything newer than 5.3.6 (which is the last working version) starting with 5.4.5 (including the latest version 5.6.1) fails with a message like

C:\temp5>"c:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -classpath . -Djava.library.path="C:\temp5" LoadTest
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\temp5\librocksdbjni-win64.dll: A dynamic link library (DLL) initialization routine failed
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at LoadTest.main(LoadTest.java:3)

If I use the older versions (like 5.3.6), there's no output.

I'm running Win 10 Version 10.0.15063.

@adamretter
Copy link
Collaborator

@qzo Please see my comment above

@qzo
Copy link

qzo commented Aug 12, 2017

I have read your comment many times. Not sure what else I can do, there's no more output. As I said, the behavior is different between 5.3.6 (and older versions, which work) and 5.4.5 (and later versions, which don't work).

@adamretter
Copy link
Collaborator

@qzo Thanks for your patience, I just tested again. I need to revise the library name in the code above. Also java.library.path should of course point to a directory containing the DLL rather than the DLL itself. Please can you try again with the changes?

@qzo
Copy link

qzo commented Aug 14, 2017

Your new version of the LoadTest class is what I've been using from the beginning (I fixed the library name and added the semicolon), so unfortunately I can't tell you anything new. If it's a new problem it might be some incompatibility with the new Windows 10 update ("Creator's Update"). But I'm only guessing. If there's anything else I can try, just tell me.

Just in case: I have latest Visual C++ redistributables (2017 for x86 and x64, 2013 for x86 and x64 and some older versions; trying to install 2015 only results in an error message "another version of this product is already installed").

@adamretter
Copy link
Collaborator

@qzo Does -Xcheck:jni shed any further light on the problem?

@adamretter
Copy link
Collaborator

Also, could you try dumpbin and depwalker to check you don't have any missing dependencies?

@qzo
Copy link

qzo commented Aug 14, 2017

No, -Xcheck:jni doesn't change the output.

I haven't tried dumpbin yet, since I'll probably need to install Visual Studio - I'll do it later, if needed. But I've attached some output from Dependency Walker. I've tried it earlier, but found out, that the API-MS-WIN* errors are probably misleading:
https://social.msdn.microsoft.com/Forums/en-US/a28331ae-19a3-4a34-b3ba-1e8fd4430375/missing-apimswincore-dlls?forum=windowsgeneraldevelopmentissues
https://ofekshilon.com/2016/03/27/on-api-ms-win-xxxxx-dll-and-other-dependency-walker-glitches/

librocksdbjni-win64.txt
librocksdbjni-win64-2.csv.txt

@adamretter
Copy link
Collaborator

adamretter commented Aug 15, 2017

@qzo I am wondering if it is the version of the C++ redistributable that you have. RocksJava is built using Visual Studio 2015. On my Windows system I have C++ redistributables 2012, 2013 and 2015.

Perhaps you could try uninstalling 2017, installing 2015 and then re-installing 2017? I believe this issue also describes that problem - #2622

I also updated the Wiki with a note here - https://github.com/facebook/rocksdb/wiki/RocksJava-Basics#maven-windows

@qzo
Copy link

qzo commented Aug 15, 2017

Didn't help. After uninstalling 2017 redistributables, I got a different error (with the same stacktrace):
Can't find dependent libraries

Then after installing 2015 redistributables, I again got
A dynamic link library (DLL) initialization routine failed
Then after installing 2017 redistributables, again:
A dynamic link library (DLL) initialization routine failed

Then I checked "Programs and Features" in Control Panel and 2015 redistributables are again missing from the list...

I'll try dumpbin tomorrow.

EDIT: I ran dumpbin:

C:>"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x86\dumpbin.exe" /DEPENDENTS c:\temp\rocksdb\librocksdbjni-win64.dll
Microsoft (R) COFF/PE Dumper Version 14.11.25506.0
Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file c:\temp\rocksdb\librocksdbjni-win64.dll

File Type: DLL

Image has the following dependencies:

RPCRT4.dll
MSVCP140.dll
VCRUNTIME140.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
KERNEL32.dll

Summary

   14000 .data
    1000 .gfids
   1F000 .pdata
   EC000 .rdata
    3000 .reloc
    1000 .rsrc
  2F4000 .text
    1000 .tls

@vadsh
Copy link

vadsh commented Aug 19, 2017

I have exactly the same problem described by qzo

@adamretter
Copy link
Collaborator

@vadsh Did you try installing the C++ 2015 redistributable package from Microsoft?

@vadsh
Copy link

vadsh commented Aug 21, 2017

@adamretter
I have Microsoft Visual Studio 2015 installed
Version 14.0.25431.01 Update 3

When I try to install C++ 2015 redistributable from this link provided by you in another thread 6 days ago:
https://www.microsoft.com/en-us/download/details.aspx?id=48145
I receive the following error message:
https://prnt.sc/gbct3d

from installation log:
[3A1C:0884][2017-08-21T23:45:49]e000: Error 0x80070666: Cannot install a product when a newer version is installed.

Exactly as qzo did.

The latest version I've managed to compile without errors and use is 5.2.1
I've done it by this manual:
https://github.com/facebook/rocksdb/wiki/Building-on-Windows
All the later versions (after 5.2.1) throw some errors (errors vary from version to version).

@vadsh
Copy link

vadsh commented Aug 21, 2017

@adamretter
Here are all the c++ redist i have installed:
http://prntscr.com/gbczvj

@jormungander
Copy link

I have the same issue on Windows 7. Using the test code that @adamretter provided, it loads for 5.3.6, but does not load with 5.4.5 or after.

@adamretter
Copy link
Collaborator

I am not sure how I can help further with this, as I am unable to reproduce the issue here. If anyone can tell me how to start step-by-step with a clean Windows 10 installation and reproduce the issue with Visual Studio 2015, I would be willing to follow the steps exactly, if I can reproduce it, we can likely fix it.

@jormungander
Copy link

I can't help you with Windows 10 repro steps, but I can say that I tried it on another, much cleaner, Windows 7 machine and had the same issue, even after building rocksdb locally. Works fine on Linux for me though. I will be getting a Windows 10 machine in the next month or two and I'll give it a try on that.

@wjlight
Copy link

wjlight commented Nov 27, 2017

@adamretter
hi, I use rocksdbjni-5.8.6.jar in windows10,
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\xxx\AppData\Local\Temp\librocksdbjni948865322637392821.dll:A dynamic link library (DLL) initialization routine failed
use VS2017,
When I use Dependency Walker, missing
API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL API-MS-WIN-CORE-COMM-L1-1-0.DLL API-MS-WIN-CORE-CONSOLE-L1-1-0.DLL API-MS-WIN-CORE-CONSOLE-L2-1-0.DLL API-MS-WIN-CORE-DATETIME-L1-1-1.DLL API-MS-WIN-CORE-DATETIME-L1-1-2.DLL API-MS-WIN-CORE-DEBUG-L1-1-1.DLL API-MS-WIN-CORE-DELAYLOAD-L1-1-1.DLL API-MS-WIN-CORE-ENCLAVE-L1-1-0.DLL API-MS-WIN-CORE-ERRORHANDLING-L1-1-1.DLL API-MS-WIN-CORE-ERRORHANDLING-L1-1-3.DLL API-MS-WIN-CORE-FIBERS-L1-1-1.DLL API-MS-WIN-CORE-FIBERS-L2-1-1.DLL API-MS-WIN-CORE-FILE-L1-2-1.DLL API-MS-WIN-CORE-FILE-L1-2-2.DLL API-MS-WIN-CORE-FILE-L2-1-1.DLL API-MS-WIN-CORE-FILE-L2-1-2.DLL API-MS-WIN-CORE-HANDLE-L1-1-0.DLL API-MS-WIN-CORE-HEAP-L1-2-0.DLL API-MS-WIN-CORE-HEAP-L2-1-0.DLL API-MS-WIN-CORE-INTERLOCKED-L1-2-0.DLL API-MS-WIN-CORE-IO-L1-1-1.DLL API-MS-WIN-CORE-JOB-L1-1-0.DLL API-MS-WIN-CORE-LIBRARYLOADER-L1-2-0.DLL API-MS-WIN-CORE-LIBRARYLOADER-L1-2-2.DLL API-MS-WIN-CORE-LIBRARYLOADER-L2-1-0.DLL API-MS-WIN-CORE-LOCALIZATION-L1-2-1.DLL API-MS-WIN-CORE-LOCALIZATION-L2-1-0.DLL API-MS-WIN-CORE-LOCALIZATION-PRIVATE-L1-1-0.DLL API-MS-WIN-CORE-MEMORY-L1-1-2.DLL API-MS-WIN-CORE-MISC-L1-1-0.DLL API-MS-WIN-CORE-NAMEDPIPE-L1-2-0.DLL API-MS-WIN-CORE-NAMEDPIPE-L1-2-2.DLL API-MS-WIN-CORE-NAMESPACE-L1-1-0.DLL API-MS-WIN-CORE-NORMALIZATION-L1-1-0.DLL API-MS-WIN-CORE-PROCESSENVIRONMENT-L1-2-0.DLL API-MS-WIN-CORE-PROCESSSNAPSHOT-L1-1-0.DLL API-MS-WIN-CORE-PROCESSTHREADS-L1-1-2.DLL API-MS-WIN-CORE-PROCESSTHREADS-L1-1-3.DLL API-MS-WIN-CORE-PROCESSTOPOLOGY-L1-2-0.DLL API-MS-WIN-CORE-PROFILE-L1-1-0.DLL API-MS-WIN-CORE-PSAPI-ANSI-L1-1-0.DLL API-MS-WIN-CORE-PSAPI-L1-1-0.DLL API-MS-WIN-CORE-REALTIME-L1-1-0.DLL API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL API-MS-WIN-CORE-RTLSUPPORT-L1-2-0.DLL API-MS-WIN-CORE-SIDEBYSIDE-L1-1-0.DLL API-MS-WIN-CORE-STRING-L1-1-0.DLL API-MS-WIN-CORE-SYNCH-L1-2-0.DLL API-MS-WIN-CORE-SYNCH-L1-2-1.DLL API-MS-WIN-CORE-SYSINFO-L1-2-1.DLL API-MS-WIN-CORE-SYSINFO-L1-2-3.DLL API-MS-WIN-CORE-THREADPOOL-L1-2-0.DLL API-MS-WIN-CORE-THREADPOOL-LEGACY-L1-1-0.DLL API-MS-WIN-CORE-THREADPOOL-PRIVATE-L1-1-0.DLL API-MS-WIN-CORE-TIMEZONE-L1-1-0.DLL API-MS-WIN-CORE-WINDOWSERRORREPORTING-L1-1-0.DLL API-MS-WIN-CORE-WOW64-L1-1-0.DLL API-MS-WIN-CORE-WOW64-L1-1-1.DLL API-MS-WIN-CORE-XSTATE-L2-1-0.DLL API-MS-WIN-CRT-CONVERT-L1-1-0.DLL API-MS-WIN-CRT-ENVIRONMENT-L1-1-0.DLL API-MS-WIN-CRT-FILESYSTEM-L1-1-0.DLL API-MS-WIN-CRT-HEAP-L1-1-0.DLL API-MS-WIN-CRT-LOCALE-L1-1-0.DLL API-MS-WIN-CRT-MATH-L1-1-0.DLL API-MS-WIN-CRT-MULTIBYTE-L1-1-0.DLL API-MS-WIN-CRT-RUNTIME-L1-1-0.DLL API-MS-WIN-CRT-STDIO-L1-1-0.DLL API-MS-WIN-CRT-STRING-L1-1-0.DLL API-MS-WIN-CRT-TIME-L1-1-0.DLL API-MS-WIN-CRT-UTILITY-L1-1-0.DLL API-MS-WIN-EVENTING-PROVIDER-L1-1-0.DLL API-MS-WIN-SECURITY-APPCONTAINER-L1-1-0.DLL API-MS-WIN-SECURITY-BASE-L1-2-0.DLL API-MS-WIN-CORE-CRT-L1-1-0.DLL API-MS-WIN-CORE-CRT-L2-1-0.DLL API-MS-WIN-CORE-HEAP-OBSOLETE-L1-1-0.DLL API-MS-WIN-CORE-KERNEL32-LEGACY-L1-1-1.DLL API-MS-WIN-CORE-STRING-OBSOLETE-L1-1-0.DLL API-MS-WIN-CORE-UTIL-L1-1-0.DLL API-MS-WIN-CRT-PRIVATE-L1-1-0.DLL API-MS-WIN-DEVICES-CONFIG-L1-1-1.DLL API-MS-WIN-DEVICES-QUERY-L1-1-1.DLL API-MS-WIN-EVENTING-CLASSICPROVIDER-L1-1-0.DLL API-MS-WIN-EVENTING-OBSOLETE-L1-1-0.DLL API-MS-WIN-SECURITY-LSALOOKUP-L1-1-1.DLL API-MS-WIN-SECURITY-LSAPOLICY-L1-1-0.DLL API-MS-WIN-SECURITY-SDDL-L1-1-0.DLL API-MS-WIN-SERVICE-MANAGEMENT-L1-1-0.DLL API-MS-WIN-SERVICE-MANAGEMENT-L2-1-0.DLL API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL API-MS-WIN-SERVICE-WINSVC-L1-2-0.DLL EXT-MS-WIN-ADVAPI32-NPUSERNAME-L1-1-0.DLL EXT-MS-WIN-ADVAPI32-NTMARTA-L1-1-0.DLL EXT-MS-WIN-ADVAPI32-REGISTRY-L1-1-0.DLL EXT-MS-WIN-APPMODEL-DAXCORE-L1-1-0.DLL EXT-MS-WIN-APPXDEPLOYMENTCLIENT-APPXDEPLOY-L1-1-0.DLL EXT-MS-WIN-APPXDEPLOYMENTCLIENT-APPXDEPLOYONECORE-L1-1-0.DLL EXT-MS-WIN-AUTHZ-CONTEXT-L1-1-0.DLL EXT-MS-WIN-COM-PSMREGISTER-L1-2-1.DLL EXT-MS-WIN-CORE-WINRT-REMOTE-L1-1-0.DLL EXT-MS-WIN-FECLIENT-ENCRYPTEDFILE-L1-1-0.DLL EXT-MS-WIN-GPAPI-GROUPPOLICY-L1-1-0.DLL EXT-MS-WIN-KERNEL32-APPCOMPAT-L1-1-0.DLL EXT-MS-WIN-KERNEL32-DATETIME-L1-1-0.DLL EXT-MS-WIN-KERNEL32-ERRORHANDLING-L1-1-0.DLL EXT-MS-WIN-KERNEL32-FILE-L1-1-0.DLL EXT-MS-WIN-KERNEL32-QUIRKS-L1-1-0.DLL EXT-MS-WIN-KERNEL32-QUIRKS-L1-1-1.DLL EXT-MS-WIN-KERNEL32-REGISTRY-L1-1-0.DLL EXT-MS-WIN-KERNEL32-SIDEBYSIDE-L1-1-0.DLL EXT-MS-WIN-KERNEL32-WINDOWSERRORREPORTING-L1-1-0.DLL EXT-MS-WIN-KERNEL32-WINDOWSERRORREPORTING-L1-1-1.DLL EXT-MS-WIN-KERNELBASE-PROCESSTHREAD-L1-1-0.DLL EXT-MS-WIN-MRMCORER-RESMANAGER-L1-1-0.DLL EXT-MS-WIN-NTDSAPI-ACTIVEDIRECTORYCLIENT-L1-1-0.DLL EXT-MS-WIN-NTDSAPI-ACTIVEDIRECTORYCLIENT-L1-1-1.DLL EXT-MS-WIN-NTUSER-STRING-L1-1-0.DLL EXT-MS-WIN-RPC-SSL-L1-1-0.DLL EXT-MS-WIN-RTCORE-NTUSER-WINDOW-EXT-L1-1-0.DLL EXT-MS-WIN-SECURITY-CAPAUTHZ-L1-1-0.DLL EXT-MS-WIN-SECURITY-EFSWRT-L1-1-1.DLL EXT-MS-WIN-SHELL32-SHELLCOM-L1-1-0.DLL
How can I solve it ?

@horiavmuntean
Copy link

Same here, at least I can confirm 5.3.6 works, 5.9.2 does not on Microsoft Windows [Version 10.0.16299.192] with Microsoft Visual C++ Redistributable 2015(x64)

@petehannam
Copy link

petehannam commented Feb 11, 2018

So apparently DependencyWalker doesn't work on 'modern' windows machine, which is why it reports that it can't find all the standard DLLs such as 'API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL'. The problem/solution is described here.

Using the recommended Dependencies tool it reports that no DLLs are missing for RocksDB:

image

I'm going to keep digging away but it doesn't look like the problem is a missing DLL issue for 5.9.2 on Windows 10.0.16299.192.

Edit: As mentioned by @qzo 5.3.6 works fine on the same machine. It stops working in 5.4.5 onwards (the next version available in MavenLink).

@davispw
Copy link

davispw commented Feb 16, 2018

Also experiencing this on a stock Windows 10 install. Any updates or hints? Absolutely blocking.

@petehannam
Copy link

petehannam commented Feb 16, 2018 via email

@hildo
Copy link

hildo commented Sep 7, 2018

Can confirm still happening on a Windows 10 machine. Only way I could load the library was using version 5.3.6 as listed above

@nihathrael
Copy link

nihathrael commented Mar 6, 2019

I retried this today with RocksDB version 5.17.2 on Windows 10 Pro Version 1809 Build 17736.316 and it works. Either the problem was fixed or my specific setup works for some reason.
If I can provide any data to help with narrowing down the bug, let me know what you need!

Of course I needed to install https://www.microsoft.com/en-us/download/details.aspx?id=48145 for RocksDB to work at all under Windows.

@adamretter
Copy link
Collaborator

adamretter commented Mar 7, 2019

For some previous versions a dependency on AVX2 exetensions crept in. More recently we are building a more CPU portable version for RocksJava.

@qzo
Copy link

qzo commented Mar 8, 2019

5.17.2 works for me as well, thank you. I'm on Ivy Bridge (no AVX2) btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests