Share libraries: dl.dll not found lazarus / 62-General ---------------------------------------------------------------------- Borneq · 2019-12-12 20:48 I test https://www.freepascal.org/docs-html/current/prog/progse56.html where is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function dlopen(name: pchar;mode: longint):pointer;cdecl;external ’dl’;Function dlsym(lib: pointer; name: pchar):pointer;cdecl;external ’dl’;Function dlclose(lib: pointer):longint;cdecl;external ’dl’;And I can't find this library in FPC distribution. I found only c:\svn\fpc\rtl\unix\dl.pp ---------------------------------------------------------------------- marcov · 2019-12-12 20:51 That code and example is for Linux only. A portable substitute is probably using unit dynlibs ---------------------------------------------------------------------- Borneq · 2019-12-12 21:09 Thanks, it works (except, it can't change literals in example) - what do SafeLoadLibrary? I read it save FPU state. - how share GetMem/FreeMem along dll's/so's ? - is possible export classes and use it? ---------------------------------------------------------------------- marcov · 2019-12-12 21:12 Quote from: Borneq on December 12, 2019, 10:09:06 pmThanks, it works (except, it can't change literals in example) - what do SafeLoadLibrary? I read it save FPU state. - how share GetMem/FreeMem along dll's/so's ? - is possible export classes and use it? SafeLoadLibrary, I don't know exactly, for the rest see https://wiki.freepascal.org/packages ---------------------------------------------------------------------- PascalDragon · 2019-12-13 08:29 Quote from: Borneq on December 12, 2019, 10:09:06 pmThanks, it works (except, it can't change literals in example) What do you mean? Quote from: Borneq on December 12, 2019, 10:09:06 pm- what do SafeLoadLibrary? I read it save FPU state. It stores the FPU and SSE state on x86 processors before loading the library and restores it afterwards. Quote from: Borneq on December 12, 2019, 10:09:06 pm- how share GetMem/FreeMem along dll's/so's ? If you simply pass a memory to a library, but the library does not free it (or the other way round) then it will work without problems. However if you have memory that is allocated in e.g. the program, but freed in the library then you need to use a shared memory manager. You can either have both parts use the C memory manager by using the cmem unit or you can pass the program's memory manager to the library (by using GetMemoryManager and SetMemoryManager). A common memory manager is also required if you want to pass managed types like AnsiString or dynamic arrays between the program and the library. Interfaces work without a common memory manager however. Quote from: Borneq on December 12, 2019, 10:09:06 pm- is possible export classes and use it? Short answer: no Long answer: as long as you don't rely on the RTTI (which includes is and as operators as well as exceptions) you can use them. To use them in a safe way requires working dynamic packages support which is still a Work In Progress.