macoslibvlcunsatisfiedlinkerrorvlcj

VLCJ on Mac OSX Unsatisfied Link Error (darwin/libvlc.dylib)


I'm trying to initialize VLCJ to do some streaming as part of an application I'm working on. Going by the official tutorial, I'm using the following code to try and load the library:

NativeLibrary.addSearchPath(
    RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC/Contents/MacOS/lib"
    );
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

When I run it, I get the following error:

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)

It looks like it's not even searching the path that I gave it. There is a perfectly good libvlc.dylib inside that directory.

Here is the output from running the 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

Solution

  • Turns out it was just a silly mistake on my part. The path I gave was "/Applications/VLC/Contents/MacOS/lib", and it should have been "/Applications/VLC.app/Contents/MacOS/lib". I forgot that VLC had a .app extension. I'll go bury my head in the sand now.