Plugin support for builded applications lazarus / 8-Other ---------------------------------------------------------------------- Sora-Kun · 2010-09-12 21:32 Hi, I want to know, if there is a way, to allow people to write plugins for my builded Lazarus-Program. I find this task VERY HARD, or even impossible. Thank you. ---------------------------------------------------------------------- JuhaManninen · 2010-09-13 07:02 You can use dynamic shared libraries (.dll, .so) and load then from your program as needed. About like:   http://www.drbob42.com/delphi/headconv.htm Just define an API that plugin writers should use. Juha ---------------------------------------------------------------------- Sora-Kun · 2010-09-13 14:09 hi, Thanks man, but is this tool cross-platfrom ? ---------------------------------------------------------------------- theo · 2010-09-13 14:55 Quote from: Linkos on September 13, 2010, 04:09:37 pmhi, Thanks man, but is this tool cross-platfrom ? I think Juha didn't mean to use this tool, but to read the information. There is h2pas which is similar http://wiki.freepascal.org/H2Pas, but I don't think a header conversion tool helps for your plugins. To your question. It depends. What should this plugin do? Should it be written in Pascal only or in C? Does it have visual parts or does it only return data? Maybe even Pascalscript could do the job? http://wiki.freepascal.org/Pascal_Script ---------------------------------------------------------------------- vvzh · 2010-09-13 14:59 Yes, but plugins must be compiled for each platform, just like your program. Alternatively, you can use scripting language such as PascalScript or Lua for writing plugins. This way plugin developers would not need to compile their plugins for all platforms your program supports. ---------------------------------------------------------------------- JuhaManninen · 2010-09-13 18:53 Quote from: Linkos on September 13, 2010, 04:09:37 pmThanks man, but is this tool cross-platfrom ? Sorry, I selected a little wrong link for this purpose. The essential point for calling a shared lib is (copied from the page): Hbar := LoadLibrary('MyPlugin.DLL'); // or LoadLibrary('MyPlugin.so'); ... Foo := GetProcAddress(HBar, 'FOO'); ... Foo(1);  // Call the func! ... FreeLibrary(HBar); The lib can be programmed with any language but FPC/Lazarus is maybe easiest. I haven't used script languages for plugins but they look promising. They don't even require compilation. On the other hand building the code is not a big problem. Still, the main challenge for plugins is to define API that allows the program and plugins to communicate. It must be done for scripts and for compiled plugins. Juha ---------------------------------------------------------------------- JD · 2010-09-14 05:21 Pascal Script can do the job. I don't know what kind of application you are writing that needs plugin support but consider the following example: a movie catalog application. These applications search for information on movies from websites like IMDB, Amazon, DVDEmpire etc. In this case, the "plugins" are the IMDB plugin, Amazon plugin, DVDEmpire etc. The code that does the searching can be in pascal script so you can add, update or remove movie extraction  information at will. I actually know an application that was built like it & I really like its flexibility.