Dylib on MacOS

Trying to call a dylib on macOS, I’ve tried @executable_path without any success. When I try direct, available returns false.

Static available As Boolean
If Not available Then available = System.IsFunctionAvailable("libvlc_new", "/Users/neo/Downloads/RB-libvlc-master-2/lib/libvlc.5.dylib")
Return available

Directory structure looks like this:


If I dump the dylib, the function is present:
nm -gU libvlc.5.dylib

0000000000001fe4 T _libvlc_new

What am I doing wrong?

This path in a constant works fine for me: @executable_path/…/Frameworks/libcrypto.0.9.8.dylib

If you like to interface VLC, you may want to try the MBS Xojo VLC Plugin with the VLC classes. The plugin wraps the methods and handles memory and threading for you.


Thanks Christian. And thanks for your contribution to RB/Xojo over the years. I understand MBS has a lot of functionality, I use it for other things, but you could be more helpful, if you know what I mean.

I know you can help with the answer to this question, AND ALSO offer MBS Plugins…if you know what I mean.

I followed the thread by Marco and replicated the folder structure.

With the @execution_path as

Still not working… (ugh!)

Still returns false

Well, the libraries have dependencies.
So you need to recreate the folder structure just like within the VLC app.
This way one of the libs can find the others. Only if libvlc finds the others, you can run a declare to it.

1 Like

That execution path still isn’t right. Consider the structure of a package:


The binary is in the macOS directory so these paths need to be relative to that. If you put your folder inside the Frameworks directory, the path would be:


1 Like

Thanks Greg!

I tried a different approach and created a build step to copy the vlc libraries into the Frameworks folder.

So the built application (My Application) looks like this:

changed the constant to:

Still not working, returns false

Checked a few dozen times, I think I have everything in place, does this look right?

Just because it’s in there does not mean that it’s been loaded though. You need a call to dlopen to get that, but unfortunately I’m not near my computer. Labor Day holiday and all

1 Like

This is the way;
you need to load the dylib before you can access it’s functions.

Since when? Is this a Mac thing? It seems to just work on Windows.

My guess would be since the beginning. You can have the OS load the dylib at launch time, which requires hacking the executable after Xojo has built it or you can use a declare to dynamically load the lib at runtime. Other tools allow you to specify what gets loaded when the app loads.

Being lazy, I packaged my GCD code into a CIFilter (yeah, yeah I know) and then loaded the filter at run time and that’s how I was able to do multi-core processing.

Othertimes I’ve tried to use system functionality and have had to load the framework via NSBundle calls.

No, not at all.

I’m just trying to get this GitHub demo to work on MacOS :wink:

Still not working and I must be missing something, spend a large part of the last two days on it. ;(

My guess on the dlopen requirement would be somewhere in between. I have had success with the RB-libssh2 wrapper. It does not call dlopen.

However, reviewing the thread about the last time this RB-libvlc / Mac issue came up, I was only able to successfully get past the System.IsFunctionAvailable check. The declares / functions themselves did not work.

I suspect that if dlopen was used to load all of the VLC libraries it may have.