5

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
Parker Kemp
  • 719
  • 1
  • 10
  • 23
  • You know you have two different sets of JNA jar files in that path? You should remove one of them. Anyway, which JDK, which VLC version? The most common problem is mixing 32-bit and 64-bit. You should also try running the vlcj "NativeDiscoveryTest". I just tried it on OSX 10.9.2 and it worked just fine for me. – caprica Apr 14 '14 at 18:26
  • I noticed that as well. I had added the 4.1.0 JNA files to the build path and subsequently removed the older ones; however, for some reason they were still showing up in the error message until I restarted Eclipse. I edited my post with the updated error message (essentially the same, minus the older .jars). – Parker Kemp Apr 14 '14 at 18:44
  • And what about my other suggestion/questions? – caprica Apr 14 '14 at 18:48
  • Apologies, I was just looking into your other suggestion with the intention of commenting again afterwards. I'm using VLC 2.1.4 and JDK 6. My VLC is 64 bit, and so is my Mac (and from what I've seen, VLCJ itself isn't specific to one or the other?). I'm running OSX 10.8.5 by the way. – Parker Kemp Apr 14 '14 at 18:53
  • By the way, I updated my JNA files because the ones packaged with the VLCJ .jars were out of date according to this page: http://caprica.github.io/vlcj/. Was that the correct thing to do on my part? – Parker Kemp Apr 14 '14 at 18:56
  • 1. Is your JVM definitely 64-bit? 2. For your JNA question, what you did *should* work, but the current release of vlcj was built and tested against JNA 3.5.2. 3. Also try -Djna.debug-load when you start your JVM – caprica Apr 14 '14 at 18:59
  • I just double-checked using the "sun.arch.data.model" property, and it is a 64-bit JVM. This might be a dumb question, but how would I go about using the -Djna.debug-load argument when compiling with Eclipse? I added it to the "VM arguments" on my run configuration, but I'm not seeing anything new in the output. – Parker Kemp Apr 14 '14 at 19:58
  • Also, I ran the NativeDiscoveryTest (copied the code into a new project, added all the vlcj jars as well as the JNA 3.5.2 jars to the build path). I edited my post to include the resulting output. It seems to be able to find libvlc.dylib and libvlccore.dylib, but can't find several other files which it doesn't specify. Or I'm just misinterpreting it. – Parker Kemp Apr 14 '14 at 20:20
  • Never mind... I just found my mistake, and it was fairly stupid. Thanks for your help. – Parker Kemp Apr 14 '14 at 20:23
  • This is an actual problem with VLC 3.0.0. None of the above helps. – John Smith Apr 11 '17 at 17:18

3 Answers3

4

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.

Parker Kemp
  • 719
  • 1
  • 10
  • 23
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

This is the macOS version. It worked for me. Maybe help you.

├── kotlin
│   └── App.kt
└── resources
    └── darwin
        ├── libvlc.dylib
        ├── libvlccore.dylib
        └── vlc
            └── plugins
                ├── liba52_plugin.dylib
                ├── libaccess_concat_plugin.dylib
                ├── libaccess_imem_plugin.dylib
                ├── libaccess_mms_plugin.dylib
BaiJiFeiLong
  • 3,716
  • 1
  • 30
  • 28
0

I update vlcj maven dependency to:

    <dependency>
        <groupId>uk.co.caprica</groupId>
        <artifactId>vlcj</artifactId>
        <version>3.12.1</version>
    </dependency>

and it works