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

VLC 3.0.1 released and VLCJ fails to link to the binaries on OSX #602

Closed
leogps opened this issue Mar 26, 2018 · 17 comments
Closed

VLC 3.0.1 released and VLCJ fails to link to the binaries on OSX #602

leogps opened this issue Mar 26, 2018 · 17 comments
Labels

Comments

@leogps
Copy link

leogps commented Mar 26, 2018

VLCJ 3.0.1 fails to link properly with VLC 3.0.1(Code name Vetenari) on OSX and also on Windows.
It works perfectly on Linux(Ubuntu) but fails with Unsatisfied link error.
It loads the plugins_path and the libvlc path correctly but fails to link to the binaries.
Reference: https://get.videolan.org/vlc/3.0.1/macosx/vlc-3.0.1.dmg

@caprica
Copy link
Owner

caprica commented Mar 26, 2018

See #601 and maybe #542.

To make any sort of reasonable progress an issue needs to include something more than "stuff doesn't work".

@leogps
Copy link
Author

leogps commented Mar 26, 2018

The error message:

java.lang.UnsatisfiedLinkError: Unable to load library 'vlc': Native library (darwin/libvlc.dylib) not found in resource path ([file:/Applications/VLC.app/Contents/MacOS/lib])
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
	at com.sun.jna.Library$Handler.<init>(Library.java:147)
	at com.sun.jna.Native.loadLibrary(Native.java:412)
	at com.sun.jna.Native.loadLibrary(Native.java:391)

Will add more info as I debug.

@leogps
Copy link
Author

leogps commented Mar 27, 2018

Enabled debug logs for JNA and working with vlc 2.2.6, the successful linking of vlc logs as follows:

Looking in classpath from sun.misc.Launcher$AppClassLoader@40affc70 for /com/sun/jna/darwin/libjnidispatch.jnilib
Found library resource at jar:file:/Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/player-ui/target/ItunesMediaPlayer-jar-with-dependencies.jar!/com/sun/jna/darwin/libjnidispatch.jnilib
Looking for library 'c'
Adding paths from jna.library.path: null
Trying libc.dylib
Found library 'c' at libc.dylib
Looking for library 'vlc'
Adding paths from jna.library.path: null
Trying /Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/LibVLC/macOs/intel-64_2.2.6/lib/libvlc.dylib
Found library 'vlc' at /Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/LibVLC/macOs/intel-64_2.2.6/lib/libvlc.dylib

When using VLC 3.0.1, the failure logs for JNA as follows:

Looking in classpath from sun.misc.Launcher$AppClassLoader@1ef6a746 for /com/sun/jna/darwin/libjnidispatch.jnilib
Found library resource at jar:file:/Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/player-ui/target/ItunesMediaPlayer-jar-with-dependencies.jar!/com/sun/jna/darwin/libjnidispatch.jnilib
Looking for library 'c'
Adding paths from jna.library.path: null
Trying libc.dylib
Found library 'c' at libc.dylib
Looking for library 'vlc'
Adding paths from jna.library.path: null
Trying /Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/LibVLC/macOs/intel-64_3.0.1/lib/libvlc.dylib
Adding system paths: [/usr/lib, /usr/lib]
Trying /Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/LibVLC/macOs/intel-64_3.0.1/lib/libvlc.dylib
Looking for matching frameworks
Looking in classpath from sun.misc.Launcher$AppClassLoader@1ef6a746 for vlc
ERROR 2018-03-26 23:57:46,256 [main] (Main.java:103) - VLCJ initialization failed!!
java.lang.UnsatisfiedLinkError: Unable to load library 'vlc': Native library (darwin/libvlc.dylib) not found in resource path ([file:/Users/leogps/Documents/Working_Projects/ILP/Projects/ItunesMediaPlayer/player-ui/target/ItunesMediaPlayer-jar-with-dependencies.jar, file:/Users/leogps/Library/Caches/IntelliJIdea2017.3/captureAgent/debugger-agent.jar, file:/Applications/IntelliJ%20IDEA.app/Contents/lib/asm-all.jar])
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
	at com.sun.jna.Library$Handler.<init>(Library.java:147)
	at com.sun.jna.Native.loadLibrary(Native.java:502)
	at com.sun.jna.Native.loadLibrary(Native.java:481)
	at uk.co.caprica.vlcj.binding.LibVlc.<clinit>(LibVlc.java:115)
	at uk.co.caprica.vlcj.version.LibVlcVersion.<clinit>(LibVlcVersion.java:32)
	at uk.co.caprica.vlcj.discovery.mac.DefaultMacNativeDiscoveryStrategy.onFound(DefaultMacNativeDiscoveryStrategy.java:66)
	at uk.co.caprica.vlcj.discovery.NativeDiscovery.discover(NativeDiscovery.java:125)
	at com.gps.itunes.media.player.vlcj.VLCJUtils.triggerNativeDiscovery(VLCJUtils.java:62)
	at com.gps.itunes.media.player.vlcj.VLCJUtils.<clinit>(VLCJUtils.java:47)
	at com.gps.itunes.media.player.ui.Main.main(Main.java:97)

@caprica
Copy link
Owner

caprica commented Mar 27, 2018

Did you look at #601, did you see in particular the notes about setting environment variables and System Integrity Protection?

@caprica
Copy link
Owner

caprica commented Mar 27, 2018

As an aside you can in fact eliminate vlcj from this issue completely, all you need to try is Native.loadLibrary("libvlc") - which is not vlcj code - and you will see the same problem.

@leogps
Copy link
Author

leogps commented Mar 27, 2018

I will try and debug as suggested but just FYI, it works successfully with vlc 2.2.8 as opposed to what's reported in #601. It's vlc 3.0.1 where it starts failing.

@caprica
Copy link
Owner

caprica commented Mar 27, 2018

That is an interesting distinction if you have it working with 2.2.x on OSX and they do not.

@00Deez
Copy link

00Deez commented Mar 28, 2018

Just wanted to add a data point to this issue. I can confirm leogps's claim. VLC 3.0.1 gives me the exact same exception. I've downgraded to VLC 2.2.8 and the NativeDiscover().discover() method detects it without any issue. Also can confirm VLC 3.0.1 on the PC (Windows 10) discover the libvlc files without issue. Haven't bothered trying to test it on my ubuntu machine since it seems you develop on it, therefore I wouldn't expect any issues.

java version "1.8.0_144" macOS from Oracle
macOS High Sierra 10.13.3

Just found this library this morning, very cool project. I can appreciate the work you've put into this.

@leogps
Copy link
Author

leogps commented Mar 28, 2018

The otool shared library info for VLC 2.2.8 describes @loader_path and VLC 3.0.1 describes @Rapth
VLC 2.2.8:

otool -L libvlc.dylib 
libvlc.dylib:
	@loader_path/lib/libvlc.5.dylib (compatibility version 11.0.0, current version 11.1.0)
	@loader_path/../lib/libvlccore.8.dylib (compatibility version 9.0.0, current version 9.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

VLC 3.0.1

otool -L libvlc.dylib 
libvlc.dylib:
	@rpath/libvlc.dylib (compatibility version 12.0.0, current version 12.0.0)
	@rpath/libvlccore.dylib (compatibility version 10.0.0, current version 10.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

I have researched and read that @Rapth (run-paths) are fairly new in OSX and I am suspecting that JNA might not understand them at the moment.
I am looking into a way to generate '.dylib' file the old way, i.e., using @loader_path. I believe install_name_tool is used on OSX to accomplish the task. Any help in accomplishing is appreciated.

@valnaumov
Copy link

@leogps install_name_tool -change @rpath/libvlccore.dylib @loader_path/../lib/libvlccore.dylib ./libvlc.dylib
worked for me

@caprica
Copy link
Owner

caprica commented Apr 1, 2018

@valnaumov very interesting, thanks

@leogps
Copy link
Author

leogps commented Apr 2, 2018

@valnaumov Thanks bro. You beat me to it and thank you for that.

After fixing the otool output looks like this:

otool -L libvlc.dylib
libvlc.dylib:
	@rpath/libvlc.dylib (compatibility version 12.0.0, current version 12.0.0)
	@loader_path/../lib/libvlccore.dylib (compatibility version 10.0.0, current version 10.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

Attaching the fixed libvlc.dylib file here for reference:
libvlc.dylib.zip

@leogps leogps changed the title VLC 3.0.1 released and VLCJ fails to link to the binaries on OSX (and Windows) VLC 3.0.1 released and VLCJ fails to link to the binaries on OSX Apr 6, 2018
@leogps
Copy link
Author

leogps commented Apr 6, 2018

The issue was only with OSX and I can confirm that it can be resolved by using the otool above. The fixed, libvlc.dylib is already attached to this issue.
The same is leveraged in the vlcj powered Media Player:
https://github.com/leogps/ItunesMediaPlayer/releases/tag/1.0.5_OSX

@leogps leogps closed this as completed Apr 6, 2018
@jowett01
Copy link

@valnaumov thanks, it works for me! This problem happened also in OSX.

@acely
Copy link

acely commented Sep 11, 2018

install_name_tool Works for me, thanks very much!

@caprica
Copy link
Owner

caprica commented Jan 2, 2019

Maybe see #643, this might be fixed for you in the next version of vlcj (if it's the same problem).

@caprica
Copy link
Owner

caprica commented Jan 25, 2019

For anyone coming across this issue, please see #643, you do NOT need to do anything with rpath, otool or any other such nasty workaround. If you use the latest vlcj this issue should be gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants