From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: LoadLibrary problem
Date: Sun, 11 Jan 2004 20:54:29 -0600
Date: 2004-01-11T20:54:29-06:00 [thread overview]
Message-ID: <hZnMb.31463$qC.15980@bignews3.bellsouth.net> (raw)
In-Reply-To: Xns946DEEAEE1E18Szymon.Guz@193.110.122.80
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
>
>
next prev parent reply other threads:[~2004-01-12 2:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-11 22:27 LoadLibrary problem Szymon Guz
2004-01-12 2:54 ` David C. Hoos [this message]
2004-01-12 6:18 ` tmoran
2004-01-12 16:20 ` Szymon Guz
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox