Forum > macOS / Mac OS X
How to load dylib for fpwebview demos?
Cascade:
I’d like to run the demo projects provided with the fpwebview library, but so far I can’t get them to run. For example, the demo ‘lclembed’ compiles successfully (so the compiler is finding the dylib OK for linking), but when the app is run the dylib does not seem to load.
If I run from the Lazarus IDE, I get a SIGABRT error message. If I run by double clicking the executable file directly in Finder, then terminal opens and displays the following output:
--- Code: ---/Users/ … /FPWebView/demo/lclembed/lclembed ; exit;
dyld: Library not loaded: libwebview.dylib
Referenced from: /Users/ … /FPWebView/demo/lclembed/lclembed
Reason: image not found
zsh: abort /Users/ … /FPWebView/demo/lclembed/lclembed
[Process completed]
--- End code ---
I’m on macOS Catalina 10.15.7, so I’ve tried different versions of the dylib, including one that indicates it was built on Catalina (10.15)
Any ideas what the issue might be?
How can I build the dylib myself?
TRon:
--- Quote from: Cascade on October 25, 2024, 05:49:50 pm ---Any ideas what the issue might be?
--- End quote ---
That you are able to build the project is not the same as at runtime loading the library..
In layman terms: File not found.
Now, my knowledge on macOS is nil but on Linux I would have to add the directory where the library is located to the "library path" (or when the library was installed with the package manager, install the dev-package of that specific library in case it exist) . I have no idea how either of these would have to be done on/for MacOS (* see edit).
Note that you might also be able to produce this message when one of the dependencies (from libwebview) cannot be loaded (which effectively fails loading libwebview itself).
--- Quote ---How can I build the dylib myself?
--- End quote ---
No idea tbh but also not required.
* edit: see wiki (turns out you can do similar on MacOS as for Linux. Please read the whole page as well, especially the package creation with Lazarus in case that has your interest).
PierceNg:
--- Quote from: Cascade on October 25, 2024, 05:49:50 pm ---I’d like to run the demo projects provided with the fpwebview library, but so far I can’t get them to run. For example, the demo ‘lclembed’ compiles successfully (so the compiler is finding the dylib OK for linking), but when the app is run the dylib does not seem to load.
I’m on macOS Catalina 10.15.7, so I’ve tried different versions of the dylib, including one that indicates it was built on Catalina (10.15)
--- End quote ---
The script macbuild.sh copies the pre-built dylib before building the lclembed executable. Once built, try running it from a shell prompt in the demo/lclembed directory:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---./lclembed
My x86_64 MBP now runs Monterey, no longer Catalina. Just tested and this procedure still works.
As for double-clicking on the app in Finder, it doesn't work for now, because of macOS-isms about @rpath. I need to poke at this a bit more with otool and install_name_tool to fix.
PierceNg:
Please try 'apr2024' branch. lclembed.app is now runnable by double clicking in Finder and also by "open lclembed.app" at the shell prompt. Tested on my x86_64 Monterey MBP: It works on my computer.TM Build the app by running macbuild.sh and macpostbuild.sh in turn. Curiously I wasn't able to build the app from within Lazarus (3.6) IDE, to be investigated.
I also have an aarch64 MBP running Sonoma to be tested.
Key changes:
- Copying libwebview.dylib and web content into the app bundle using the script macpostbuild.sh.
- Accounting for macOS-isms like rpath and installed names.
Note the setup misses some best practices:
- The dylib ought to be wrapped into a framework and installed in the Frameworks directory within the app bundle.
- The web content ought to be in the Resources directory within the app bundle.
PierceNg:
Also tested working on aarch64 macOS Sonoma. I've merged the fixes into master: https://github.com/PierceNg/fpwebview
Navigation
[0] Message Index
[#] Next page