comp.lang.ada
 help / color / mirror / Atom feed
From: Per Sandberg <per.sandberg@bredband.net>
To: comp.lang.ada@ada-france.org
Subject: Re: function from dll
Date: Fri, 23 Jan 2004 07:05:14 +0100
Date: 2004-01-23T07:05:14+01:00	[thread overview]
Message-ID: <mailman.5.1074837935.2270.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <bupck6$rqm$1@nemesis.news.tpi.pl>

Why don do an lib file that contains all symbols in the dll
and then link the library and avoid messing around with liad libraray 
and such.
Unless you requere dynamic loading ofd the dll in runtime.

sample code

<C-code>
external C{  // to avoid C++ name mangling.
void sth(){};
}
</C-code>

<Ada-code
procedure sth;
pragma import (<C or Stdcal>,sth,"sth");
pragma Linker_Options("-llibname"); -- GNAT specific.
<How-to>
#if GNAT then

How to create a lib-file
copy the libname.lib to liblibname.a
then gnatmake -L<the directory where liblibname.a is> <other params>
#elseif ObjectAda then
In project properties
add libname.lib to linker arguments
Add the directory wher libname.lib resides in
the "Linker only" search list.
#end if;
</How-to>
<Ada-code>
/Per Sandberg


Szymon Guz wrote:

> Hi,
> I've got maybe a trivial question but I still can't solve the problem:
> 
> I've a dll written in C under Windows and I want to use specific 
> function from that in my Ada program. For loading the library I use the 
> WinApi function LoadLibrary and then I use the function GetProcAddress 
> to get the Win32.Windef.FARPROC handle to the function that I need. I 
> need to map the function from the dll in Ada to have sth like that:
> 
> <C++ CODE>
> void sth(){}
> </C++ CODE>
> 
> <ADA CODE>
> function sth() return Integer;
> </ADA CODE>
> 
> now I want to run in the ada function body the function from dll... well 
> how to use the Win32.Windef.FARPROC handle ?
> 
> Szymon Guz
> 
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
> 




      parent reply	other threads:[~2004-01-23  6:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-22 20:36 function from dll Szymon Guz
2004-01-22 23:43 ` Stephen Leake
2004-01-23  1:59   ` tmoran
2004-01-23  6:05 ` Per Sandberg [this message]
replies disabled

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