无法加载libvlc:无法加载库' vlc'

时间:2018-03-04 01:07:57

标签: java vlc libvlc vlcj

我刚开始使用jlcj制作自己的视频播放器。 我尝试了教程,但总是无法加载libvlc.dylib。

我知道互联网上有很多同样的问题和解决方案。 但是我尝试了它们但仍然发生了错误。

这是一个运行uk.co.caprica.vlcj.test.environment.TroubleShooter的日志。 能不能告诉我这个问题和解决方案的原因。

============================== 8< 8< 8< ==============================

Library name: vlc
libvlc shared object file name: libvlc.dylib
libvlc core shared object file name: libvlccore.dylib

SYSTEM PROPERTIES:
 awt.toolkit=sun.lwawt.macosx.LWCToolkit
 file.encoding=UTF-8
 file.encoding.pkg=sun.io
 file.separator=/
 ftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
 gopherProxySet=false
 http.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
 java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
 java.awt.printerjob=sun.lwawt.macosx.CPrinterJob
 java.class.path=/Users/yasuosaito/Development/Workspace/vlcj/target/test-classes:/Users/yasuosaito/Development/Workspace/vlcj/target/classes:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna-platform/4.1.0/jna-platform-4.1.0.jar:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-api/1.7.10/slf4j-api-1.7.10.jar:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar:/Users/yasuosaito/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar
 java.class.version=52.0
 java.endorsed.dirs=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/endorsed
 java.ext.dirs=/Users/yasuosaito/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
 java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
 java.io.tmpdir=/var/folders/69/5_506wls4bj9vms7bsmg8q2h0000gn/T/
 java.library.path=/Users/yasuosaito/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
 java.runtime.name=Java(TM) SE Runtime Environment
 java.runtime.version=1.8.0_144-b01
 java.specification.name=Java Platform API Specification
 java.specification.vendor=Oracle Corporation
 java.specification.version=1.8
 java.vendor=Oracle Corporation
 java.vendor.url=http://java.oracle.com/
 java.vendor.url.bug=http://bugreport.sun.com/bugreport/
 java.version=1.8.0_144
 java.vm.info=mixed mode
 java.vm.name=Java HotSpot(TM) 64-Bit Server VM
 java.vm.specification.name=Java Virtual Machine Specification
 java.vm.specification.vendor=Oracle Corporation
 java.vm.specification.version=1.8
 java.vm.vendor=Oracle Corporation
 java.vm.version=25.144-b01
 jna.library.path=/Applications/VLC.app/Contents/MacOS/lib
 jna.platform.library.path=/usr/lib:/usr/lib
 jnidispatch.path=/var/folders/69/5_506wls4bj9vms7bsmg8q2h0000gn/T/jna-1072754801/jna328949766312094835.tmp
 os.arch=x86_64
 os.name=Mac OS X
 os.version=10.13.2
 path.separator=:
 socksNonProxyHosts=local|*.local|169.254/16|*.169.254/16
 sun.arch.data.model=64
 sun.boot.class.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/classes
 sun.boot.library.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib
 sun.cpu.endian=little
 sun.cpu.isalist=
 sun.io.unicode.encoding=UnicodeBig
 sun.java.command=uk.co.caprica.vlcj.test.environment.Troubleshooter
 sun.java.launcher=SUN_STANDARD
 sun.jnu.encoding=UTF-8
 sun.management.compiler=HotSpot 64-Bit Tiered Compilers
 sun.os.patch.level=unknown
 user.country=JP
 user.dir=/Users/yasuosaito/Development/Workspace/vlcj
 user.home=/Users/yasuosaito
 user.language=ja
 user.name=yasuosaito
 user.timezone=

ARCHITECTURE TELLS:
 java.vm.name=Java HotSpot(TM) 64-Bit Server VM
 os.arch=x86_64
 sun.arch.data.model=64

PATH=/usr/bin:/bin:/usr/sbin:/sbin
 /usr/bin      
 /bin      
 /usr/sbin      
 /sbin      

jna.library.path=/Applications/VLC.app/Contents/MacOS/lib
 /Applications/VLC.app/Contents/MacOS/lib   found libvlc   found libvlccore

java.library.path=/Users/yasuosaito/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
 /Users/yasuosaito/Library/Java/Extensions      
 /Library/Java/Extensions      
 /Network/Library/Java/Extensions      
 /System/Library/Java/Extensions      
 /usr/lib/java      
 .      

Note that JNA does not use java.library.path, it is searched here for completeness.

LD_LIBRARY_PATH=<not-specified>

Load Library:
 Failed to load libvlc: Unable to load library 'vlc': Native library (darwin/libvlc.dylib) not found in resource path ([file:/Users/yasuosaito/Development/Workspace/vlcj/target/test-classes/, file:/Users/yasuosaito/Development/Workspace/vlcj/target/classes/, file:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar, file:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna-platform/4.1.0/jna-platform-4.1.0.jar, file:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-api/1.7.10/slf4j-api-1.7.10.jar, file:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar, file:/Users/yasuosaito/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar])

============================== 8< 8< 8< ==============================

Note that CPU architecture detection is an informed *guess*, it may not be accurate.

It looks like you have a 64-bit OS because os.arch=x86_64.

It looks like you have a 64-bit JVM because java.vm.name=Java HotSpot(TM) 64-Bit Server VM.

If you are running a 64-bit JVM, then you need a 64-bit build of vlc.

If you only have a 32-bit build of vlc, then you can use a 32-bit JVM on your 64-bit OS.

libvlc was found in the following locations:
 /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib

libvlccore was found in the following locations:
 /Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib

libvlc could not be loaded.

============================== 8< 8< 8< ==============================

libvlc and libvlccore were found, so if the JVM CPU architecture matches your vlc build CPU architecture, you should be able to resolve this with configuration...

Some things to try:

Set this system property on the command-line      : -Djna.library.path=/Applications/VLC.app/Contents/MacOS/lib
Set this system property in your Java code        : System.setProperty("jna.library.path", "/Applications/VLC.app/Contents/MacOS/lib");
Add this statement to your Java code              : NativeLibrary.addSearchPath("vlc", "/Applications/VLC.app/Contents/MacOS/lib");
Add this directory to your operating system path  : /Applications/VLC.app/Contents/MacOS/lib

I will try setting the jna.library.path system property to '/Applications/VLC.app/Contents/MacOS/lib' for you...
 Failed to load libvlc: Unable to load library 'vlc': Native library (darwin/libvlc.dylib) not found in resource path ([file:/Users/yasuosaito/Development/Workspace/vlcj/target/test-classes/, file:/Users/yasuosaito/Development/Workspace/vlcj/target/classes/, file:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar, file:/Users/yasuosaito/.m2/repository/net/java/dev/jna/jna-platform/4.1.0/jna-platform-4.1.0.jar, file:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-api/1.7.10/slf4j-api-1.7.10.jar, file:/Users/yasuosaito/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar, file:/Users/yasuosaito/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar])

============================== 8< 8< 8< ==============================

1 个答案:

答案 0 :(得分:0)

cd src/main/resources/
cp -r /Applications/VLC.app/Contents/MacOS/lib darwin
rm darwin/*.*.*
cd darwin
install_name_tool -add_rpath @loader_path libvlc.dylib
mkdir vlc
cp -r /Applications/VLC.app/Contents/MacOS/plugins vlc/plugins

只为懒惰的人。它对我有用,也许对您有帮助。