* LoadLibrary problem
@ 2004-01-11 22:27 Szymon Guz
2004-01-12 2:54 ` David C. Hoos
0 siblings, 1 reply; 4+ messages in thread
From: Szymon Guz @ 2004-01-11 22:27 UTC (permalink / raw)
Hi,
I keep on trying to load a dll library using for that the WinApi
function LoadLibrary.
<CODE>
with Interfaces.C;
procedure Lib is
package C renames Interfaces.C;
use type C.Char_Array;
function LoadLib (
Library : in C.Char_Array )
return C.Int;
pragma Import(C,LoadLib,"LoadLibrary");
Handle : C.Int;
begin
Handle:=LoadLib("a");
end Lib;
</CODE>
I still get the linker error:
./Lib.o(.text+0x12):Lib.adb: undefined reference to `LoadLibrary'
Where is the mistake ?
I'm using gnat and AdaGIDE under Windows98.
--
Szymon Guz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: LoadLibrary problem
2004-01-11 22:27 LoadLibrary problem Szymon Guz
@ 2004-01-12 2:54 ` David C. Hoos
2004-01-12 6:18 ` tmoran
2004-01-12 16:20 ` Szymon Guz
0 siblings, 2 replies; 4+ messages in thread
From: David C. Hoos @ 2004-01-12 2:54 UTC (permalink / raw)
The mistake is that you need to tell the linker where to find the file
that contains the "LoadLibrary" object code.
If you use the Win32ada library, it's found in libole32.a.
What's more, instead of writing your own interface, you can use
the imports provided in the win32-winbase.ads file, viz.:
pragma Import(Stdcall, LoadLibraryA, "LoadLibraryA"); --
winbase.h:3619
pragma Import(Stdcall, LoadLibraryW, "LoadLibraryW"); --
winbase.h:3625
pragma Import(Stdcall, LoadLibraryExA, "LoadLibraryExA"); --
winbase.h:3637
pragma Import(Stdcall, LoadLibraryExW, "LoadLibraryExW"); --
winbase.h:3645
Also, note that the C calling convention is not the proper convention for
use with
Win32 libraries.
I hope this helps
"Szymon Guz" <alpha@SMIECI_WON.skynet.org.pl> wrote in message
news:Xns946DEEAEE1E18Szymon.Guz@193.110.122.80...
> Hi,
> I keep on trying to load a dll library using for that the WinApi
> function LoadLibrary.
>
> <CODE>
> with Interfaces.C;
>
>
> procedure Lib is
> package C renames Interfaces.C;
> use type C.Char_Array;
>
> function LoadLib (
> Library : in C.Char_Array )
> return C.Int;
>
> pragma Import(C,LoadLib,"LoadLibrary");
>
> Handle : C.Int;
>
>
>
> begin
> Handle:=LoadLib("a");
> end Lib;
> </CODE>
>
> I still get the linker error:
> ./Lib.o(.text+0x12):Lib.adb: undefined reference to `LoadLibrary'
>
> Where is the mistake ?
>
> I'm using gnat and AdaGIDE under Windows98.
>
> --
> Szymon Guz
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: LoadLibrary problem
2004-01-12 2:54 ` David C. Hoos
@ 2004-01-12 6:18 ` tmoran
2004-01-12 16:20 ` Szymon Guz
1 sibling, 0 replies; 4+ messages in thread
From: tmoran @ 2004-01-12 6:18 UTC (permalink / raw)
>What's more, instead of writing your own interface, you can use
>the imports provided in the win32-winbase.ads file, viz.:
>
> pragma Import(Stdcall, LoadLibraryA, "LoadLibraryA"); --
>winbase.h:3619
> ...
>Also, note that the C calling convention is not the proper convention for
>use with Win32 libraries.
Or you could use Claw:
package CLAW.DLL is ...
type DLL_Type is new Ada.Finalization.Controlled with private;
procedure Load (DLL_Object: in out DLL_Type;
DLL_File: in String);
...
and let it worry about things like Ada->C strings, proper finalization of
the handle, and StdCall vs C.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: LoadLibrary problem
2004-01-12 2:54 ` David C. Hoos
2004-01-12 6:18 ` tmoran
@ 2004-01-12 16:20 ` Szymon Guz
1 sibling, 0 replies; 4+ messages in thread
From: Szymon Guz @ 2004-01-12 16:20 UTC (permalink / raw)
David C. Hoos wrote:
> The mistake is that you need to tell the linker where to find the file
> that contains the "LoadLibrary" object code.
>
> If you use the Win32ada library, it's found in libole32.a.
>
> What's more, instead of writing your own interface, you can use
> the imports provided in the win32-winbase.ads file, viz.:
>
> pragma Import(Stdcall, LoadLibraryA, "LoadLibraryA"); --
> winbase.h:3619
> pragma Import(Stdcall, LoadLibraryW, "LoadLibraryW"); --
> winbase.h:3625
> pragma Import(Stdcall, LoadLibraryExA, "LoadLibraryExA"); --
> winbase.h:3637
> pragma Import(Stdcall, LoadLibraryExW, "LoadLibraryExW"); --
> winbase.h:3645
>
> Also, note that the C calling convention is not the proper convention for
> use with
> Win32 libraries.
>
> I hope this helps
>
yea, that helped a lot
tnx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-12 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-11 22:27 LoadLibrary problem Szymon Guz
2004-01-12 2:54 ` David C. Hoos
2004-01-12 6:18 ` tmoran
2004-01-12 16:20 ` Szymon Guz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox