Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java JNI DLL UnsatisfiedLinkError error

  1. #1
    Junior Member
    Join Date
    Sep 2024
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Java JNI DLL UnsatisfiedLinkError error

    I have a strange problem with my camera JNI windows DLL program. I can load and run immaculately on Windows 10 machine on which the DLL program was developed.

    When I copy to Windows 11 another machine, I get the unsatisfied Java module load error. It says "cannot find dependent libraries". It works on Windows 10. Not in another machine! The following is a stack trace;

    java.lang.UnsatisfiedLinkError: C:\Users\XXXX\AppData\Local\Temp\AnamonCamera-win64.dll10819000438203799267: Can't find dependent libraries
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryI mpl.open(Unknown Source)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(Un known Source)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(Un known Source)
    at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.base/java.lang.Runtime.load0(Unknown Source)
    at java.base/java.lang.System.load(Unknown Source)
    at anamon.camera.Webcam.<clinit>(Webcam.java:43)
    at anamon.cms.ImageStereoVision.run(ImageStereoVision .java:372)
    at java.base/java.lang.Thread.run(Unknown Source)

    The following is JNI Visual Studio C++ program snippets which shows included libraries and APIs used. It's basic camera interface program that get a list of camera names and fetch images from a camera. It uses Media Foundation APIs which is win32 which doesn't require extra installations.

    #include "jni.h"

    #include <mfapi.h>
    #include <mfidl.h>
    #include <mfreadwrite.h>

    #pragma comment(lib, "mf.lib")
    #pragma comment(lib, "mfuuid.lib")
    #pragma comment(lib, "mfplat.lib")
    #pragma comment(lib, "mfreadwrite.lib")

    // JNI interface functions call this;
    int setupCameraDeviceList() {
    HRESULT hr;
    if (!mfinitialized) {
    hr = MFStartup(MF_VERSION);
    if (FAILED(hr)) {
    return -3;
    }
    }

    hr = MFCreateAttributes(&videoConfig, 1);
    if (FAILED(hr)) {
    return -4;
    }

    ......
    }


    The following is Java DLL loading part. It extracts DLL file stored in a Jar file and store on a temp file. Then the temp file is loaded;

    String dllname = "AnamonCamera-win64";
    File temp = WebcamTools.extractInJarDllFileAndCreateTempFile(d llname);
    System.load(temp.getAbsolutePath());
    temp.delete();


    The following is Visual Studion CMakeLists.txt file.

    cmake_minimum_required (VERSION 3.8)

    # Enable Hot Reload for MSVC compilers if supported.
    if (POLICY CMP0141)
    cmake_policy(SET CMP0141 NEW)
    set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_I D:MSVC>>,$<$<CONFIGebug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIGebug,RelWithDebInforogramDatabase>>")
    endif()

    project ("AnamonCameraMF-win6")

    add_library( # Sets the name of the library.
    AnamonCamera-win64

    # Sets the library as a shared library.
    SHARED

    # Provides a relative path to your source file(s).
    AnamonCameraMF.cpp
    )

    I suspect this CMakeLists.txt file may need something. Otherwise it could be visual studio license or java or windows security issue. Currently I subscribed monthly. Probably not charged yet.

    It could be I am making a simple mistake as I am not expert on Visual Studio matter. I use Visual Studio 2022 professional and community editions.

  2. #2
    Junior Member
    Join Date
    Sep 2024
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Java JNI DLL UnsatisfiedLinkError error

    I solved this problem. I was using DEBUG version DLL. After switching to release version, it works fine. So using a debug version didn't work.

  3. The Following User Says Thank You to oh122 For This Useful Post:

    Norm (September 4th, 2024)

Similar Threads

  1. Slick2D Runnable Jar Not Running (java.lang.UnsatisfiedLinkError)
    By Epicballzy in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 4th, 2014, 03:03 AM
  2. (JNA) java.lang.UnsatisfiedLinkError: Unable to load library
    By Shockah in forum Java Native Interface
    Replies: 4
    Last Post: October 3rd, 2011, 11:29 AM
  3. Help ! java.lang.UnsatisfiedLinkError
    By CTheSky in forum Java Theory & Questions
    Replies: 1
    Last Post: July 7th, 2011, 12:50 PM
  4. [SOLVED] UnsatisfiedLinkError
    By tecno40 in forum Java Native Interface
    Replies: 5
    Last Post: June 12th, 2011, 03:08 AM
  5. java.lang.UnsatisfiedLinkError
    By H P in forum Java Native Interface
    Replies: 3
    Last Post: January 28th, 2010, 05:04 AM

Tags for this Thread