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

OpenCV dll loading order seems wrong, resulting in UnsatisifedLinkError #606

Closed
dkgof opened this issue Aug 21, 2018 · 5 comments
Closed
Labels

Comments

@dkgof
Copy link

dkgof commented Aug 21, 2018

When loading the dll files for opencv the loader tries to load:

concrt140.dll
msvcp140.dll
vcruntime140.dll

before all the api-ms-win dlls, which does not work, as the former 3 depend on the later.

This results in UnsatisfiedLinkError when loading the first 3 dlls, and then later when trying to load the opencv dlls, because the former failed.

Manually installing vc runtime 2015 fixes this, but kinda defeats the purpose of having the dll's included in the first place.

Test app just tries to do the following to load the lib:

opencv_core.Point2d point = new opencv_core.Point2d(0, 0);
System.out.println(""+point);

From console:

Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\concrt140.dll
Failed to load C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\concrt140.dll: java.lang.UnsatisfiedLinkError: C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\concrt140.dll: Can't find dependent libraries
Loading library concrt140
Failed to load for concrt140: java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jre1.8.0_181\bin\concrt140.dll: Can't find dependent libraries
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\msvcp140.dll
Failed to load C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\msvcp140.dll: java.lang.UnsatisfiedLinkError: C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\msvcp140.dll: Can't find dependent libraries
Loading library msvcp140
Failed to load for msvcp140: java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jre1.8.0_181\bin\msvcp140.dll: Can't find dependent libraries
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\vcruntime140.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-locale-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-string-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-stdio-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-math-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-heap-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-runtime-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-convert-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-environment-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-time-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-filesystem-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-utility-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-multibyte-l1-1-0.dll
Loading C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\opencv_core342.dll
Failed to load C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\opencv_core342.dll: java.lang.UnsatisfiedLinkError: C:\Users\rolf\.javacpp\cache\opencv-3.4.2-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\opencv_core342.dll: Can't find dependent libraries
Loading library opencv_core342
Failed to load for opencv_core342: java.lang.UnsatisfiedLinkError: no opencv_core342 in java.library.path
@saudet saudet added the bug label Aug 21, 2018
@dkgof
Copy link
Author

dkgof commented Aug 21, 2018

From further inspection it seems vcruntime140.dll does not require the api-ms dlls, and loads correctly, so its only the other 2 that needs to be loaded after.

@dkgof
Copy link
Author

dkgof commented Aug 21, 2018

Looking through the source code inside javacpp-presets/opencv/src/main/java/org/bytedeco/javacpp/presets/opencv_core.java:

@Platform(value = "windows", define = "_WIN32_WINNT 0x0502", link =  {"opencv_core342", "opencv_imgproc342"}, preload = {"concrt140", "msvcp140", "vcruntime140",
        "api-ms-win-crt-locale-l1-1-0", "api-ms-win-crt-string-l1-1-0", "api-ms-win-crt-stdio-l1-1-0", "api-ms-win-crt-math-l1-1-0",
        "api-ms-win-crt-heap-l1-1-0", "api-ms-win-crt-runtime-l1-1-0", "api-ms-win-crt-convert-l1-1-0", "api-ms-win-crt-environment-l1-1-0",
        "api-ms-win-crt-time-l1-1-0", "api-ms-win-crt-filesystem-l1-1-0", "api-ms-win-crt-utility-l1-1-0", "api-ms-win-crt-multibyte-l1-1-0", "opencv_cudev342"})

Should probabely be changed to:

@Platform(value = "windows", define = "_WIN32_WINNT 0x0502", link =  {"opencv_core342", "opencv_imgproc342"}, preload = {
        "api-ms-win-crt-locale-l1-1-0", "api-ms-win-crt-string-l1-1-0", "api-ms-win-crt-stdio-l1-1-0", "api-ms-win-crt-math-l1-1-0",
        "api-ms-win-crt-heap-l1-1-0", "api-ms-win-crt-runtime-l1-1-0", "api-ms-win-crt-convert-l1-1-0", "api-ms-win-crt-environment-l1-1-0",
        "api-ms-win-crt-time-l1-1-0", "api-ms-win-crt-filesystem-l1-1-0", "api-ms-win-crt-utility-l1-1-0", "api-ms-win-crt-multibyte-l1-1-0", "concrt140", "msvcp140", "vcruntime140", "opencv_cudev342"})

Moving the problem dlls to the end of the preload list, instead of at the beginning.

@saudet
Copy link
Member

saudet commented Aug 25, 2018

Should be fixed now, please try it with the snapshots:
http://bytedeco.org/builds/
Thanks for reporting!

@dkgof
Copy link
Author

dkgof commented Aug 27, 2018

Latest snapshot, fixes this problem :)

Thanks for the quick response!

@saudet
Copy link
Member

saudet commented Oct 16, 2018

Fix included in version 1.4.3! Thanks again for reporting.

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

No branches or pull requests

2 participants