Anna Blanca 0 Posted yesterday at 07:22 PM Hello. How i can use LoadLibrary in FMX, on the not-Windows platforms? When i try wright 'LoadLibrary' in FMX-project, it emphasized by red. That is, FMX not supporting this function. It's working, when i connected WinAPI, but i want use dynamic connect for dynamic libraryes, not on the Windows. Share this post Link to post
Remy Lebeau 1512 Posted 22 hours ago (edited) LoadLibrary() is a Win32 API function, so it is only available on Windows, you CAN'T use it on other platforms. That being said, other platforms have their own equivalents. For example, 'Nix-based platforms (which includes OSX, iOS, Linux, and Android) have dlopen() instead. You are going to have to use the appropriate API for each platform you want to support. Edited 22 hours ago by Remy Lebeau Share this post Link to post
Dave Nottage 582 Posted 20 hours ago 7 hours ago, Anna Blanca said: How i can use LoadLibrary in FMX, on the not-Windows platforms? For Posix systems (Android, iOS, macOS, Linux) use LoadLibrary from System.SysUtils - it wraps dlopen, which Remy mentioned. 1 Share this post Link to post
Remy Lebeau 1512 Posted 19 hours ago (edited) 1 hour ago, Dave Nottage said: use LoadLibrary from System.SysUtils Do you mean SafeLoadLibrary()? Edited 19 hours ago by Remy Lebeau Share this post Link to post
Dave Nottage 582 Posted 19 hours ago Just now, Remy Lebeau said: Do you mean SafeLoadLibrary()? The OP asked about LoadLibrary, so I referred to LoadLibrary. The documentation does not list it, but it's there. Share this post Link to post
Anna Blanca 0 Posted 2 hours ago (edited) 17 hours ago, Dave Nottage said: For Posix systems (Android, iOS, macOS, Linux) use LoadLibrary from System.SysUtils - it wraps dlopen, which Remy mentioned. Thank you, that's works. Normal compile. Truly, when i'm writing next code: procedure TForm1.Button1Click(Sender: TObject); var I : Integer; SoName : THandle; ExportFunc : function(X, Y : Integer) : Integer; begin SoName := LoadLibrary('/storage/emulated/0/Documents/libTestLibrary.so'); if SoName <> 0 then begin ExportFunc := GetProcAddress(SoName, 'Launch'); I := ExportFunc(3, 5); Label1.Text := IntToStr(I); end; end; Nothing not happens....Even when i writed wrong library name, app not fired out with error. Edited 2 hours ago by Anna Blanca Share this post Link to post
Dave Nottage 582 Posted 2 hours ago Just now, Anna Blanca said: Nothing not happens....Even i writed wrong library name, app not fired out with error. I expect there will be a permissions error in the system logs (which you can view using a log viewer), unless you are using an earlier version of Android and have requested the relevant permissions. On Android 11 or higher, I doubt you'll make LoadLibrary work at all using that path. Is there some reason you are not deploying libTestLibrary.so with the application? Share this post Link to post
Anna Blanca 0 Posted 2 hours ago (edited) 11 minutes ago, Dave Nottage said: Is there some reason you are not deploying libTestLibrary.so with the application? I need to launch so-library not at once, but after any time. Maybe, my app will download library from the Internet, it new version will be released.... In actualy, is Android a new iOS? Edited 2 hours ago by Anna Blanca Share this post Link to post
Dave Nottage 582 Posted 2 hours ago 5 minutes ago, Anna Blanca said: I need to launch so-library not at once, but after any time. Maybe, my app will download library from the Internet, it new version will be released.... If your app itself is downloading it, it won't need to go in a shared folder (which is what /storage/emulated/0/Documents is). The app could download it to a subfolder of the internal documents folder, e.g. a folder like this: LLibFolder := TPath.Combine(TPath.GetDocumentsPath, 'Lib'); ForceDirectories(LLibFolder); LLibFileName := TPath.Combine(LLibFolder, 'libTestLibrary.so'); Your download routine could then download the file to the filename specified by LLibFileName, and call LoadLibrary using the same path. 11 minutes ago, Anna Blanca said: In actualy, is Android a new iOS? Android and iOS are two very different operating systems. Share this post Link to post
Anna Blanca 0 Posted 1 hour ago 10 minutes ago, Dave Nottage said: If your app itself is downloading it, it won't need to go in a shared folder (which is what /storage/emulated/0/Documents is). The app could download it to a subfolder of the internal documents folder, e.g. a folder like this: O'K, thanks, but its not solved my problem - LoadLibrary not loading my library. You solution is only for simplification directly downloading from server. Share this post Link to post
Anna Blanca 0 Posted 1 hour ago 51 minutes ago, Dave Nottage said: Android and iOS are two very different operating systems. So, how can i use dynamic loading of librarys in Android 14? Share this post Link to post