Javacpp-presets: build custom module of javacpp-presets error

Created on 3 Aug 2020  Â·  25Comments  Â·  Source: bytedeco/javacpp-presets

Hi,

I followed the step in https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets and https://github.com/bytedeco/javacpp-presets/wiki/Building-on-Windows,

then run "mvn install -Djavacpp.platform=windows-x86 --projects .,libmpeg", error found:

jnilibmpeg.obj : error LNK2001: unresolved external symbol __imp_ps_demuxer_create

ps_demuxer_create is the function name in the external cpp lib.

my configures in the following:

javacpp-presets\libmpeg\src\main\java\org\bytedeco\libmpeg\presets\libmpeg.java:

@Properties(inherit=javacpp.class, target="org.bytedeco.libmpeg", global="org.bytedeco.libmpeg.global.libmpeg", value={
    @Platform(
            value = {
                    "windows-x86",
                    "windows-x86_64"
            },
            include = {
            "<mpeg-ps.h>"
       }, link = {"libmpeg"}
    )
        , @Platform(value = "windows", preload = "libmpeg")
})

public class libmpeg implements InfoMapper {
    static { Loader.checkVersion("org.bytedeco", "libmpeg"); }

    public void map(InfoMap infoMap) {
          infoMap.put(new Info("_WIN32", "NAN_API", "NOINLINE").cppTypes().annotations())
                 .put(new Info("NAN_EXPORT").cppTypes().define(false));
    }
}

javacpp-presets\libmpeg\src\main\java9\module-info.java:

module org.bytedeco.libmpeg {
  requires transitive org.bytedeco.javacpp;
  exports org.bytedeco.libmpeg.global;
  exports org.bytedeco.libmpeg.presets;
  exports org.bytedeco.libmpeg;
}

pom.xml:

<profiles>
    <profile>
      <id>msvc</id>
      <activation>
        <os><family>windows</family></os>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.bytedeco</groupId>
            <artifactId>javacpp</artifactId>
            <configuration>
              <properties>${javacpp.platform}</properties>
              <compilerOptions>
                <compilerOption>/MT</compilerOption>
              </compilerOptions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
question

Most helpful comment

Yeah, while I wrote
compile group: 'org.bytedeco', name: 'zlib-platform', version: "1.2.11-1.5.4-SNAPSHOT" instead of
compile group: 'org.bytedeco', name: 'zlib', version: "1.2.11-1.5.4-SNAPSHOT" in build.gradle

it works ok.

In org\bytedeco\javacpp\Loader.java: findResources:

        while (url == null && !urls.hasMoreElements() && path.length() > 0) {
            int n = path.lastIndexOf('/', path.length() - 2);
            if (n >= 0) {
                path = path.substring(0, n + 1);
            } else {
                path = "";
            }
            urls = classLoader.getResources(path + name);
        }
        while (urls.hasMoreElements() && (maxLength < 0 || array.size() < maxLength)) {
            url = urls.nextElement();
            if (!array.contains(url)) {
                array.add(url);
            }
        }
        return array.toArray(new URL[array.size()]);
   return ---> ` jar:file:/C:/Users/Think/.m2/repository/org/bytedeco/zlib/1.2.11-1.5.4-SNAPSHOT/zlib-1.2.11-1.5.4-SNAPSHOT-windows-x86_64.jar!/org/bytedeco/zlib/windows-x86_64/jnizlib.dll`  (!!! found reference class path automatically), otherwise return null.

All 25 comments

It looks like you're not importing/exporting symbols from your library correctly:
https://docs.microsoft.com/en-us/cpp/cpp/dllexport-dllimport

It looks like you're not importing/exporting symbols from your library correctly:
https://docs.microsoft.com/en-us/cpp/cpp/dllexport-dllimport

I did it in mpeg_ps.h, It's still the same error:

#ifndef _mpeg_ps_h_
#define _mpeg_ps_h_

#include <stdint.h>
#include <stddef.h>

#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
//#define NAN_CALL __cdecl
#if defined(NAN_EXPORT)
#define NAN_API __declspec(dllexport)
#else
#define NAN_API __declspec(dllimport)
#endif
#define NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define NAN_CALL
#define NAN_API __attribute__((visibility("default")))
#define NOINLINE __attribute__((noinline))
#else
#define NAN_CALL
#define NAN_API
#define NOINLINE
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef void(*ps_demuxer_onpacket)(void* param, int stream, int codecid, int flags, int64_t pts, int64_t dts, const void* data, size_t bytes);
NAN_API struct ps_demuxer_t* ps_demuxer_create(ps_demuxer_onpacket onpacket, void* param);

#ifdef __cplusplus
}
#endif
#endif /* !_mpeg_ps_h_ */


@saudet Can you please help me solve this issue?

Your code expects to link with a DLL, where is libmpeg.dll?

Your code expects to link with a DLL, where is libmpeg.dll?

In cppbuild.sh to build local library:

windows-*)
        echo ""
        echo "--------------------"
        echo "Building"
        echo "--------------------"
        echo ""

        if [[ $PLATFORM == "windows-x86" ]]; then
            make -j $MAKEJ RELEASE=1 PLATFORM=$PLATFORM ARCH=32 V=0
        else
            make -j $MAKEJ RELEASE=1 PLATFORM=$PLATFORM ARCH=64 V=0
        fi
......

====> libmpeg.dll

What does cl.exe /? return?

.. x86 çš„ Microsoft (R) C/C++ .. 19.16.27042
(C) Microsoft Corporation

What about dumpbin /headers libmpeg.lib and dumpbin /headers libmpeg.dll?

It may be the problem caused by x86 or x64 visual studio prompt, I'll try it out

In 64-bit windows, I built zlib-1.2.11-1.5.4-SNAPSHOT-windows-x86.jar and zlib-1.2.11-1.5.4-SNAPSHOT-windows-x86_64.jar to "C:\Users\xxxx.m2\repository\org\bytedeco\zlib\1.2.11-1.5.4-SNAPSHOT" by the steps of https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets , then running error:

no jnizlib in java.library.path
java.lang.UnsatisfiedLinkError: no jnizlib in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)

@saudet what is the reason for this?

It means it's not finding libjnizlib.dll anywhere. Where is it?

image

Could you set the "org.bytedeco.javacpp.logger.debug" system property to "true" and let me know what gets displayed on the console when it tries to load that?

Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Loader
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-locale-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-string-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-stdio-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-math-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-heap-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-runtime-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-convert-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-environment-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-time-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-filesystem-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-utility-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-crt-multibyte-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-string-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-errorhandling-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-timezone-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-file-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-namedpipe-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-handle-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-file-l2-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-heap-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-libraryloader-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-synch-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-processthreads-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-processenvironment-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-datetime-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-localization-l1-2-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-sysinfo-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-synch-l1-2-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-console-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-debug-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-rtlsupport-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-processthreads-l1-1-1.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-file-l1-2-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-profile-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-memory-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-util-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\api-ms-win-core-interlocked-l1-1-0.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\ucrtbase.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\vcruntime140.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\vcruntime140_1.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\msvcp140.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\msvcp140_1.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\concrt140.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\vcomp140.dll
Debug: Loading C:\Users\Think\.javacpp\cache\javacpp-1.5.4-SNAPSHOT-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\jnijavacpp.dll
Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Pointer
[]
Debug: Loading class org.bytedeco.zlib.global.zlib
Debug: Loading class org.bytedeco.zlib.global.zlib
Debug: Loading library jnizlib
Debug: Failed to load for jnizlib: java.lang.UnsatisfiedLinkError: no jnizlib in java.library.path

no jnizlib in java.library.path
java.lang.UnsatisfiedLinkError: no jnizlib in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1683)
    at org.bytedeco.javacpp.Loader.load(Loader.java:1300)
    at org.bytedeco.javacpp.Loader.load(Loader.java:1123)
    at org.bytedeco.zlib.global.zlib.<clinit>(zlib.java:12)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.bytedeco.javacpp.Loader.load(Loader.java:1190)
    at org.bytedeco.javacpp.Loader.load(Loader.java:1123)
    at org.bytedeco.zlib.z_stream.<clinit>(z_stream.java:14)
    at com.media.gbs.domain.codec.TestSvac.openInputSvac(TestSvac.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
    at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.lang.Thread.run(Thread.java:748)

Right, so that just means it's not finding libjnizlib.dll. You'll need to put those JAR files in your class path.

As the contrast of ffmpeg from gradle mavenCentral automatically downloaded in C:\Users\Think.gradle\caches\modules-2\files-2.1\org.bytedeco\ffmpeg\4.3.1-1.5.4-SNAPSHOT\2440042004c1a860a43f7f91efe8fce4f7e5621f\ffmpeg-4.3.1-1.5.4-SNAPSHOT-windows-x86_64.jar, then loaded to C:\Users\Think.javacpp\cache\ffmpeg-4.3.1-1.5.4-SNAPSHOT-windows-x86_64.jar,it's ok while running.

But the zlib custom preset built from mavenLocal manually to C:\Users\Think.m2\repository\org\bytedeco\svacdecoder\0.100-1.5.4-SNAPSHOT,not found in C:\Users\Think.gradle\caches\modules-2\files-2.1..., so how could i do it ? not putting those JAR files in my class path manually .

You mean how to use those JARs from Gradle? We can add repositories { mavenLocal() } for that like this:
https://github.com/bytedeco/gradle-javacpp/blob/master/samples/zlib/build.gradle#L10

Yes, how to use local custom preset jar (e.g. zlib) without putting jars file to class path manually ?

my build.gradle:

repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url = 'https://jitpack.io' } // Allows annotations past Java 8 to be used
    }

dependencies {
    compile group: 'org.bytedeco', name: 'zlib', version: "1.2.11-1.5.4-SNAPSHOT"
}

You mean the artifacts with classifiers? Do something like this, but for Windows instead of Android: https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies#including-binaries-only-for-mobile-platforms

No, I means that how the javacpp to load the built local custom presets?

And I set the class path, the same error: no jnizlib in java.library.path

image

It doesn't change anything whether they were built locally or not. They are loaded the same way.

Right, so that just means it's not finding libjnizlib.dll.

You'll need to put those JAR files in your class path. -----> How to do it?

My jars are in C:\Users\Think.m2\repository\org\bytedeco\zlib\1.2.11-1.5.4-SNAPSHOT:
image
generated by mvn install -Djavacpp.platform=windows-x86 (or windows-86_64) --projects .,zlib

And What else do I need to do to make it work?

Yeah, while I wrote
compile group: 'org.bytedeco', name: 'zlib-platform', version: "1.2.11-1.5.4-SNAPSHOT" instead of
compile group: 'org.bytedeco', name: 'zlib', version: "1.2.11-1.5.4-SNAPSHOT" in build.gradle

it works ok.

In org\bytedeco\javacpp\Loader.java: findResources:

        while (url == null && !urls.hasMoreElements() && path.length() > 0) {
            int n = path.lastIndexOf('/', path.length() - 2);
            if (n >= 0) {
                path = path.substring(0, n + 1);
            } else {
                path = "";
            }
            urls = classLoader.getResources(path + name);
        }
        while (urls.hasMoreElements() && (maxLength < 0 || array.size() < maxLength)) {
            url = urls.nextElement();
            if (!array.contains(url)) {
                array.add(url);
            }
        }
        return array.toArray(new URL[array.size()]);
   return ---> ` jar:file:/C:/Users/Think/.m2/repository/org/bytedeco/zlib/1.2.11-1.5.4-SNAPSHOT/zlib-1.2.11-1.5.4-SNAPSHOT-windows-x86_64.jar!/org/bytedeco/zlib/windows-x86_64/jnizlib.dll`  (!!! found reference class path automatically), otherwise return null.

@saudet Other question please:How to packet all dependency dlls to output jar?

e.g.

in cppbuild\windows-x86\lib: a.lib a.dll b.dll c.dll
in @Platform(value = "windows", link = { "a" })

only a.dll in output jar, I want to use a.dll b.dll c.dll in output jar.

Add preload={"b", "c"}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eix128 picture eix128  Â·  23Comments

kusaanko picture kusaanko  Â·  43Comments

mtadmk picture mtadmk  Â·  33Comments

thunterdb picture thunterdb  Â·  37Comments

Maurice-Betzel picture Maurice-Betzel  Â·  32Comments