salvadordf / WebUI4Delphi

WebUI4Delphi is a WebUI wrapper, which allows you to use any web browser as a GUI, with Delphi or Lazarus/FPC in the backend and HTML5 in the frontend.
https://www.briskbard.com/forum/
MIT License
107 stars 15 forks source link

LoadLibrary failed on MacOS #6

Closed aztack closed 1 month ago

aztack commented 1 month ago

I set a absolute dylib path to make sure it is exsits: WebUI.LibraryPath := '/Users/name/github/WebUI4Delphi/bin64/webui-2_debug.dylib';

But in following function

function TWebUI.LoadWebUILibrary: boolean;
...
FLibHandle := LoadLibrary(TempLibraryPath); // FLibHandle is 0

end;

FLibHandle is always zero.

salvadordf commented 1 month ago

In the case of MacOS applications the webui-2.dylib dynamic library must be in the MyApplication.app/Contents/Frameworks directory.

aztack commented 1 month ago

In the case of MacOS applications the webui-2.dylib dynamic library must be in the MyApplication.app/Contents/Frameworks directory.

I also tried to place webui-2_debug.dylib and webui-2.dylib in above mentioned folder but got the same error:

image
aztack commented 1 month ago

I tried to load dylib with LoadLibrary and inspect error with GetLoadErrorStr and found that the webui-2.dylib is ofMach-O 64-bit dynamically linked shared library arm64 not x64 as expected. I change project target CPU to aarch64 and it works. (see https://github.com/webui-dev/webui/issues/482)

Maybe in function TWebUI.LoadWebUILibrary : boolean; you can use GetLoadErrorStr along with GetLastOSError to get more detailed error information

salvadordf commented 1 month ago

I just added the error information in TWebUI and the Minimal demo shows it if the initialization fails.