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
…
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.
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.
That execution path still isn’t right. Consider the structure of a package:
Contents
Frameworks
MacOS
Resources
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:
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
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.