www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Object.factory from shared libraries

reply "krzaq" <dlangmailinglist krzaq.cc> writes:
I'd like to extend my program's functionality from plugins, 
that'd be loaded by name (or not) as requested by the config 
file. Is it possible to throw in a few dlls/sos implementing 
those new modules into a directory and hope that they will be all 
loaded and available to Object.factory in the main executable?

I hope I'm clear enough.
Sep 26 2014
parent reply Jacob Carlborg <doob me.com> writes:
On 26/09/14 14:37, krzaq wrote:
 I'd like to extend my program's functionality from plugins, that'd be
 loaded by name (or not) as requested by the config file. Is it possible
 to throw in a few dlls/sos implementing those new modules into a
 directory and hope that they will be all loaded and available to
 Object.factory in the main executable?

 I hope I'm clear enough.
If you either enumerate all dynamic libraries in a directory, or a list from a config file, then use dlopen on all libraries. Then I think Object.factory should work. But dynamic libraries are basically only working on Linux. -- /Jacob Carlborg
Sep 26 2014
parent reply "krzaq" <dlangmailinglist krzaq.cc> writes:
On Friday, 26 September 2014 at 14:14:05 UTC, Jacob Carlborg 
wrote:
 On 26/09/14 14:37, krzaq wrote:
 I'd like to extend my program's functionality from plugins, 
 that'd be
 loaded by name (or not) as requested by the config file. Is it 
 possible
 to throw in a few dlls/sos implementing those new modules into 
 a
 directory and hope that they will be all loaded and available 
 to
 Object.factory in the main executable?

 I hope I'm clear enough.
If you either enumerate all dynamic libraries in a directory, or a list from a config file, then use dlopen on all libraries. Then I think Object.factory should work. But dynamic libraries are basically only working on Linux.
That would be satisfactory to me, except for the linux-only part. In that case, I think I'll simply try to call filename() as the factory function in each library - that should work everywhere, right?
Sep 26 2014
parent reply Jacob Carlborg <doob me.com> writes:
On 2014-09-26 16:24, krzaq wrote:

 That would be satisfactory to me, except for the linux-only part.

 In that case, I think I'll simply try to call filename() as the factory
 function in each library - that should work everywhere, right?
Dynamic libraries only work properly on Linux. This has nothing to do with Object.factory. -- /Jacob Carlborg
Sep 26 2014
parent "Cliff" <cliff.s.hudson gmail.com> writes:
On Friday, 26 September 2014 at 15:45:11 UTC, Jacob Carlborg
wrote:
 On 2014-09-26 16:24, krzaq wrote:

 That would be satisfactory to me, except for the linux-only 
 part.

 In that case, I think I'll simply try to call filename() as 
 the factory
 function in each library - that should work everywhere, right?
Dynamic libraries only work properly on Linux. This has nothing to do with Object.factory.
What is the nature of D's so/dll support? Or is there a page describing it?
Sep 26 2014