comp.lang.ada
 help / color / mirror / Atom feed
* DLLs / shared objects
@ 2003-10-03 23:47 kat-Zygfryd
  2003-10-04  7:58 ` Patrice Freydiere
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kat-Zygfryd @ 2003-10-03 23:47 UTC (permalink / raw)


I'd like to have a plugin system in my Ada program -
loading functions/procedures from dll's/so's unknown at compiletime,
but found by the app at runtime. All information I found concerned
only Windows DLLs and involved statically linking parts of the dynamic libs,
which is unacceptable.
Is there any way in Ada to do so? (GNAT 3.14p, x86 Windows/Linux)

kZ

A schematical example of what I mean:

<DLL>
type PluginFunc is access function (someparam) return someresult;
type Callback is access procedure (FuncName: String; FuncCode: PluginFunc);
procedure Init(proc: Callback) is
begin
  proc("SomePluginFunc",MyFunc'Access);
end Init;
function MyFunc(...

<Program>
type PluginFunc is access function (someparam) return someresult;
type Callback is access procedure (FuncName: String; FuncCode: PluginFunc);
procedure SetFunc(FuncName: String; FuncCode: PluginFunc) is
begin
    Add(FuncHashTable,FuncName,FuncCode);
end SetFunc;
...
loop
  SomeDLL := FindDLL(...);
  exit when ...;
  InitProc := ObtainInitProc(SomeDLL); <--- ???
  InitProc(SetFunc);
end loop;





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DLLs / shared objects
  2003-10-03 23:47 DLLs / shared objects kat-Zygfryd
@ 2003-10-04  7:58 ` Patrice Freydiere
       [not found] ` <m2r81tn9mv.fsf@jvdsys.demon.nl>
  2003-10-04 11:03 ` chris
  2 siblings, 0 replies; 4+ messages in thread
From: Patrice Freydiere @ 2003-10-04  7:58 UTC (permalink / raw)





On Sat, 04 Oct 2003 01:47:43 +0200, kat-Zygfryd wrote:

> I'd like to have a plugin system in my Ada program -
> loading functions/procedures from dll's/so's unknown at compiletime,
> but found by the app at runtime. All information I found concerned
> ....
>   InitProc := ObtainInitProc(SomeDLL); <--- ???
>   InitProc(SetFunc);
> end loop;


Hi, 
there is solutions for each system supporting dynamic library loading.
You can use the Win API to do so for Windows plateforme
There is an example in AdaPower source repository

there is a AdaPlugin project for Linux that use Dynamic Glib Module
functionnality. (i don't remember the URL)
or DLib ->  http://www.ada-france.org/article94.html

I've never saw an ada project that make an abstraction and proprose 
a common approch of "plugin",that manage the different plateforms.

Cheers, 
Patrice



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DLLs / shared objects
       [not found] ` <m2r81tn9mv.fsf@jvdsys.demon.nl>
@ 2003-10-04 10:10   ` chris
  0 siblings, 0 replies; 4+ messages in thread
From: chris @ 2003-10-04 10:10 UTC (permalink / raw)


Jerry van Dijk wrote:
> 
> Yes, the same way as you would with C or C++. This is as you probably realize
> not a language but an OS question.
> 
> I never did this under Linux, 

Linux Dynamic Library support is provided by "dl" (man dlopen), a 
binding can be found at http://www.cyberdanx.co.uk

HTH,
Chris




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DLLs / shared objects
  2003-10-03 23:47 DLLs / shared objects kat-Zygfryd
  2003-10-04  7:58 ` Patrice Freydiere
       [not found] ` <m2r81tn9mv.fsf@jvdsys.demon.nl>
@ 2003-10-04 11:03 ` chris
  2 siblings, 0 replies; 4+ messages in thread
From: chris @ 2003-10-04 11:03 UTC (permalink / raw)


kat-Zygfryd wrote:
> I'd like to have a plugin system in my Ada program -
> loading functions/procedures from dll's/so's unknown at compiletime,
> but found by the app at runtime. All information I found concerned
> only Windows DLLs and involved statically linking parts of the dynamic libs,
> which is unacceptable.
> Is there any way in Ada to do so? (GNAT 3.14p, x86 Windows/Linux)

Try www.cyberdanx.co.uk and look for dlib.  It's not high level but it 
does bind to linux library loading facilities, and might serve as the 
basis for a higher level binding.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-04 11:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-03 23:47 DLLs / shared objects kat-Zygfryd
2003-10-04  7:58 ` Patrice Freydiere
     [not found] ` <m2r81tn9mv.fsf@jvdsys.demon.nl>
2003-10-04 10:10   ` chris
2003-10-04 11:03 ` chris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox