我正在尝试初始化 VLCJ 以将一些流作为我正在处理的应用程序的一部分。通过 official tutorial ,我使用以下代码尝试加载库:
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC/Contents/MacOS/lib"
);
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
当我运行它时,出现以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'vlc': JNA native support (darwin/libvlc.dylib) not found in resource path (/Users/iamparker/Documents/workspace/VLCStreamer/target/classes:/usr/jar/vlc/vlcj-3.0.1-javadoc.jar:/usr/jar/vlc/vlcj-3.0.1-sources.jar:/usr/jar/vlc/vlcj-3.0.1-test-sources.jar:/usr/jar/vlc/vlcj-3.0.1-tests.jar:/usr/jar/vlc/vlcj-3.0.1.jar:/usr/jar/vlc/jna-4.1.0.jar:/usr/jar/vlc/jna-platform-4.1.0.jar)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:220)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:322)
at com.sun.jna.Library$Handler.<init>(Library.java:142)
at com.sun.jna.Native.loadLibrary(Native.java:387)
at com.sun.jna.Native.loadLibrary(Native.java:366)
at com.thundercats.vlcstreamer.Main.loadNative(Main.java:33)
at com.thundercats.vlcstreamer.Main.main(Main.java:16)
看起来它甚至没有搜索我给它的路径。该目录中有一个非常好的 libvlc.dylib。
这是运行 VLCJ NativeDiscoveryTest 的输出:
vlcj: (Info.java:70) | INFO | vlcj: <version not available>
vlcj: (Info.java:71) | INFO | java: 1.6.0_65 Apple Inc.
vlcj: (Info.java:72) | INFO | java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
vlcj: (Info.java:73) | INFO | os: Mac OS X 10.8.5 x86_64
vlcj: (NativeDiscovery.java:98) | DEBUG | discover()
vlcj: (NativeDiscovery.java:101) | DEBUG | jnaLibraryPath=null
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.linux.DefaultLinuxNativeDiscoveryStrategy@42b1b4c3
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=false
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.windows.DefaultWindowsNativeDiscoveryStrategy@60072ffb
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=false
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.mac.DefaultMacNativeDiscoveryStrategy@77df38fd
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=true
vlcj: (AbstractNativeDiscoveryStrategy.java:49) | DEBUG | discover()
vlcj: (AbstractNativeDiscoveryStrategy.java:54) | DEBUG | directoryNames=[/Users/iamparker/Documents/workspace/NativeDiscoveryTest, /usr/bin, /bin, /usr/sbin, /sbin, /Applications/VLC.app/Contents/MacOS/lib]
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/Users/iamparker/Documents/workspace/NativeDiscoveryTest
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/usr/bin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/bin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/usr/sbin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/sbin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (AbstractNativeDiscoveryStrategy.java:85) | DEBUG | Matched 'libvlc.dylib' in '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (AbstractNativeDiscoveryStrategy.java:85) | DEBUG | Matched 'libvlccore.dylib' in '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (AbstractNativeDiscoveryStrategy.java:88) | DEBUG | Matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:63) | DEBUG | result=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (NativeDiscovery.java:112) | DEBUG | path=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (NativeDiscovery.java:114) | INFO | Discovery found libvlc at '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (Test.java:34) | DEBUG | found=true
vlcj: (LibVlcFactory.java:164) | INFO | vlc: 2.1.4 Rincewind, changeset 2.1.4-0-g2a072be
vlcj: (LibVlcFactory.java:165) | INFO | libvlc: /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib
vlcj: (Test.java:36) | DEBUG | Version: {}2.1.4 Rincewind
最佳答案
事实证明,这只是我的一个愚蠢的错误。我给出的路径是 "/Applications/VLC/Contents/MacOS/lib"
,它应该是 "/Applications/VLC.app/Contents/MacOS/lib"
。我忘了 VLC 有一个 .app 扩展名。我现在就去把头埋在沙子里。
关于macos - Mac OSX 上的 VLCJ 不满意链接错误 (darwin/libvlc.dylib),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23063529/