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

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

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

Post 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/
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

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

Post by Justin »

Have you tried this?

Code: Select all

SetEnvironmentVariable("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins/")
With the correct path.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

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

Post 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.
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

It weird but I don't think it's a PB command problem as we just use the standard dlopen() call.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

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

Post 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
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

Could you try by importing dlopen() ?
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

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

Post 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.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

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

Post 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?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply