Page 1 of 1

Can not open VLC-Library ver. 3.x on Mac OS, 2.x works...

Posted: Tue Jun 12, 2018 5:35 pm
by Lebostein

Code: Select all

Debug OpenLibrary(#PB_Any, "/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib")
Works with VLC 2.2.8, but don't work with the newest VLC 3.0.3

Any hints?

https://download.videolan.org/pub/videolan/vlc/

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Tue Jun 12, 2018 6:35 pm
by Justin
Have you tried this?

Code: Select all

SetEnvironmentVariable("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins/")
With the correct path.

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Tue Jun 12, 2018 7:16 pm
by Lebostein
Justin wrote:Have you tried this?

Code: Select all

SetEnvironmentVariable("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins/")
With the correct path.
Yes. I set this. But the problem is the OpenLibrary command. It seems the library can not be opened.
With Windows it works. I can open the VCL-dll with OpenLibrary() for all versions...

I found this, but I don't know if it help:
https://obsproject.com/mantis/view.php?id=1175
The VLC distribution has changed the way it packages its dylibs, which affects the ability for the VLC plugin to load them.

`otool -L` output from VLC 2.2.8:
```
/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.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)
```

`otool -L` output from VLC 3.0.0:
```
/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.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)
```

The change from `@loader_path` to `@rpath` now puts the burden on consumers of `libvlc.5.dylib` (read: OBS’ VLC plugin) to have set the `@rpath` (at compile time) to include the path to that dylib. VLC itself sets the `@rpath` appropriately from within the VLC application binary itself. This is possible because all the libraries are accessible relative to that binary.

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Tue Jun 12, 2018 7:39 pm
by Fred
It weird but I don't think it's a PB command problem as we just use the standard dlopen() call.

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Sat Feb 02, 2019 2:36 pm
by Lebostein
Same behaviour with 3.06.
It is impossible to open the VLC libvlc.5.dylib with PB since VLC version 3.x. Version 2.x works

otool -L /Applications/VLC.app/Contents/MacOS/lib/libvlc.5.dylib
/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.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)

otool -L /Applications/VLC3.app/Contents/MacOS/lib/libvlc.5.dylib
/Applications/VLC3.app/Contents/MacOS/lib/libvlc.5.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.50.4)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

Code: Select all

Debug OpenLibrary(#PB_Any, "/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.dylib") # = 4296235608
Debug OpenLibrary(#PB_Any, "/Applications/VLC3.app/Contents/MacOS/lib/libvlc.5.dylib") # = 0

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Mon Feb 04, 2019 1:08 pm
by Fred
Could you try by importing dlopen() ?

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works..

Posted: Mon Jan 06, 2020 11:17 pm
by Justin
I gave this another try and now it works.

(Tutorial for dummies)
You have to do 2 things:
change the rpath of the lib to your path
set the plugin path at run time

To change the rpath assuming your lib is located at 'yourpath/lib/'
Open a terminal, and type:
cd yourpath/lib/
Then:
install_name_tool -change @rpath/libvlccore.dylib yourpath/lib/libvlccore.dylib yourpath/lib/libvlc.dylib

You only need to do this once, I guess you will need some kind of installation if you want to redistribute it.

Then this code should work:

Code: Select all

EnableExplicit

Define.s libVlc
Define.i hlib

libVlc = "yourpath/lib/libvlc.dylib"
SetEnvironmentVariable("VLC_PLUGIN_PATH", "yourpath/plugins/")

hlib = OpenLibrary(#PB_Any, libVlc)

Debug CallFunction(hlib, "libvlc_new", 0, #Null)
Tested with the last libvlc version.

Re: Can not open VLC-Library ver. 3.x on Mac OS, 2.x works...

Posted: Wed Sep 22, 2021 2:47 pm
by collectordave
Hi All

Trying to get Libvlc working.

using the following:-

Code: Select all

EnableExplicit

Define.s libVlc
Define.i hlib

libVlc = GetUserDirectory(#PB_Directory_Documents) + "VlcTRY/VLC.app/Contents/MacOS/lib/libvlc.dylib"
SetEnvironmentVariable("VLC_PLUGIN_PATH", GetUserDirectory(#PB_Directory_Documents) + "VlcTRY/VLC.app/Contents/MacOS//plugins/")

hlib = OpenLibrary(#PB_Any, libVlc)

Debug CallFunction(hlib, "libvlc_new", 0, #Null)
I get a large number in the debug window which I assume is correct.

How do I move on from this to play an audio file?