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

Cannot find the .so file when running the jar package. #690

Open
mengpengfei opened this issue Jun 21, 2023 · 17 comments
Open

Cannot find the .so file when running the jar package. #690

mengpengfei opened this issue Jun 21, 2023 · 17 comments

Comments

@mengpengfei
Copy link

The error message can be seen in one image.
image
After I manually copied the libopencv_world.so.3.4 file over, the program ran normally.

However, the libopencv_world.so.3.4 file is already included in the jar package.
Why wasn't the libopencv_world.so.3.4 file extracted to that directory, causing me to manually copy the file over when running the program?

I have tested all versions of javacpp, but this issue still remains unsolved.
Is there any way to solve this problem?

@mengpengfei
Copy link
Author

image
From the above picture, it can be seen that the jar package already contains the so file.
Except for the file libopencv_world.so.3.4, the other two .so files were successfully extracted to the path /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar///**/linux-x86_64.

@saudet
Copy link
Member

saudet commented Jun 21, 2023

You should ask the author of that YoloApi project. I don't know anything about it.

@saudet
Copy link
Member

saudet commented Jun 21, 2023

Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.

@mengpengfei
Copy link
Author

Does it have anything to do with the caching function of javacpp? Some .so files will not be cached.

@mengpengfei
Copy link
Author

Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Loader
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/org/bytedeco/javacpp/linux-x86_64/libjnijavacpp.so
Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Pointer
Debug: Loading class top..yolo.YoloApi
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/
/yolo/linux-x86_64/libdarknet.so
Debug: Failed to load /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top//yolo/linux-x86_64/libdarknet.so: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top//yolo/linux-x86_64/libdarknet.so: libopencv_world.so.3.4: cannot open shared object file: No such file or directory

Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.

@mengpengfei
Copy link
Author

Debug: Loading library darknet
Debug: Failed to load for darknet: java.lang.UnsatisfiedLinkError: no darknet in java.library.path
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top//yolo/linux-x86_64/libjniYoloApi.so
Debug: Failed to load /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/
/yolo/linux-x86_64/libjniYoloApi.so: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/**/yolo/linux-x86_64/libjniYoloApi.so: libopencv_world.so.3.4: cannot open shared object file: No such file or directory
Debug: Loading library jniYoloApi
Debug: Failed to load for jniYoloApi: java.lang.UnsatisfiedLinkError: no jniYoloApi in java.library.path

@saudet
Copy link
Member

saudet commented Jun 21, 2023

It doesn't look like that YoloApi was designed to extract that library. Please report downstream.

@mengpengfei
Copy link
Author

These codes were written by me alone, and the jar package was generated using a Maven plugin. Below is the configuration file information for Maven.


org.bytedeco
javacpp
1.5.9
linux-x86_64


org.bytedeco
javacpp
1.5.9



        <resource>

            <directory>src/main/java</directory>

            <includes>
                <include>**/*.so*</include>
            </includes>
          
            <filtering>false</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass></mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

@mengpengfei
Copy link
Author

I write code independently without any upstream or downstream.

@saudet
Copy link
Member

saudet commented Jun 21, 2023

So, try to add "[email protected]" to the @Platform(link=... annotation value as shown here:
https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets

@mengpengfei
Copy link
Author

image

@mengpengfei
Copy link
Author

Still printed the same error.

So, try to add "[email protected]" to the @Platform(link=... annotation value as shown here: https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets

@saudet
Copy link
Member

saudet commented Jun 21, 2023

Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.

@mengpengfei
Copy link
Author

image
Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Loader
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/org/bytedeco/javacpp/linux-x86_64/libjnijavacpp.so
Debug: Loading class org.bytedeco.javacpp.presets.javacpp
Debug: Loading class org.bytedeco.javacpp.Pointer
Debug: Loading class top.dg.yolo.YoloApi
Debug: Loading library opencv_world.so.3.4
Debug: Failed to load for opencv_world.so.3.4: java.lang.UnsatisfiedLinkError: no opencv_world.so.3.4 in java.library.path
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libdarknet.so
Debug: Failed to load /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libdarknet.so: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libdarknet.so: libopencv_world.so.3.4: cannot open shared object file: No such file or directory
Debug: Loading library darknet
Debug: Failed to load for darknet: java.lang.UnsatisfiedLinkError: no darknet in java.library.path
Debug: Loading /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libjniYoloApi.so
Debug: Failed to load /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libjniYoloApi.so: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libjniYoloApi.so: libopencv_world.so.3.4: cannot open shared object file: No such file or directory
Debug: Loading library jniYoloApi
Debug: Failed to load for jniYoloApi: java.lang.UnsatisfiedLinkError: no jniYoloApi in java.library.path
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniYoloApi in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1122)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1832)
at org.bytedeco.javacpp.Loader.load(Loader.java:1423)
at org.bytedeco.javacpp.Loader.load(Loader.java:1234)
at org.bytedeco.javacpp.Loader.load(Loader.java:1210)
at top.dg.yolo.YoloApi.(YoloApi.java:10)
at top.dg.yolo.YoloTest.main(YoloTest.java:22)
Caused by: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/yolo-api-1.0-jar-with-dependencies.jar/top/dg/yolo/linux-x86_64/libjniYoloApi.so: libopencv_world.so.3.4: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1086)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1779)
... 5 more

Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.

@saudet
Copy link
Member

saudet commented Jun 21, 2023

Debug: Failed to load for opencv_world.so.3.4: java.lang.UnsatisfiedLinkError: no opencv_world.so.3.4 in java.library.path

This means "[email protected]" isn't in the @Platform(link=... annotation value
Please add "[email protected]" to the @Platform(link=... annotation value.

@mengpengfei
Copy link
Author

It is ok now! thanks very much!
I'm curious about the principle behind this setting. Is there any documentation available?

@saudet
Copy link
Member

saudet commented Jun 21, 2023

The @Platform annotation? Sure, there's a bit here:
http://bytedeco.org/javacpp/apidocs/org/bytedeco/javacpp/annotation/Platform.html

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

2 participants