comp.lang.ada
 help / color / mirror / Atom feed
* Ada,static link dll.(windows)
@ 2016-05-30  9:08 George J
  2016-05-30  9:09 ` George J
  0 siblings, 1 reply; 5+ messages in thread
From: George J @ 2016-05-30  9:08 UTC (permalink / raw)


Hi ALL!So,today I've got a problem with dll:
I have .dll (made with FASM) and I want to link it statically to my Ada project. I've always made this way (https://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Windows) by dinamically linking. So I want to link my dll statically. I've spent 6 hours and couldn't find any solution.

p.s. my way was
1. pragma Import(Stdcall,myProc,"myProc",Link_Name => "myDLL.dll");
result: undefined reference to "myDLL.dll"
2. pragma Import(Stdcall,myProc,"myProc");
result: undefined reference to myProc@8 (yes,it has to DWORD params)
and other attempts.
--------------------------------------------------------------------------

I have Thin package with 
------------------------------------
with Win32;

package Thin is

   procedure myProc
     (Major : Win32.DWORD;
      Minor : Win32.DWORD);
   pragma Import(Stdcall,myProc,"myProc"); --,Link_Name => "myDLL.dll");
   --pragma Linker_Options("-myDLL");

end Thin;
--------------------------------------

and Main proc with
--------------------------
with Thin;
procedure Main is
begin
      Thin.myProc(1,2);
end Main;
-------------------------

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

* Re: Ada,static link dll.(windows)
  2016-05-30  9:08 Ada,static link dll.(windows) George J
@ 2016-05-30  9:09 ` George J
  2016-05-30  9:39   ` Dmitry A. Kazakov
  0 siblings, 1 reply; 5+ messages in thread
From: George J @ 2016-05-30  9:09 UTC (permalink / raw)


понедельник, 30 мая 2016 г., 12:08:09 UTC+3 пользователь George J написал:
> Hi ALL!So,today I've got a problem with dll:
> I have .dll (made with FASM) and I want to link it statically to my Ada project. I've always made this way (https://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Windows) by dinamically linking. So I want to link my dll statically. I've spent 6 hours and couldn't find any solution.
> 
> p.s. my way was
> 1. pragma Import(Stdcall,myProc,"myProc",Link_Name => "myDLL.dll");
> result: undefined reference to "myDLL.dll"
> 2. pragma Import(Stdcall,myProc,"myProc");
> result: undefined reference to myProc@8 (yes,it has to DWORD params)
> and other attempts.
> --------------------------------------------------------------------------
> 
> I have Thin package with 
> ------------------------------------
> with Win32;
> 
> package Thin is
> 
>    procedure myProc
>      (Major : Win32.DWORD;
>       Minor : Win32.DWORD);
>    pragma Import(Stdcall,myProc,"myProc"); --,Link_Name => "myDLL.dll");
>    --pragma Linker_Options("-myDLL");
> 
> end Thin;
> --------------------------------------
> 
> and Main proc with
> --------------------------
> with Thin;
> procedure Main is
> begin
>       Thin.myProc(1,2);
> end Main;
> -------------------------

and BTW,I've put my DLL file in exec folder,project folder,build folder...


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

* Re: Ada,static link dll.(windows)
  2016-05-30  9:09 ` George J
@ 2016-05-30  9:39   ` Dmitry A. Kazakov
  2016-05-30 10:48     ` George J
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry A. Kazakov @ 2016-05-30  9:39 UTC (permalink / raw)


On 30/05/2016 11:09, George J wrote:
> понедельник, 30 мая 2016 г., 12:08:09 UTC+3 пользователь George J написал:
>> Hi ALL!So,today I've got a problem with dll:
>> I have .dll (made with FASM) and I want to link it statically to
>> my  Ada project. I've always made this way
>> (https://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Windows)
>> by dinamically linking. So I want to link my dll statically. I've spent
>> 6 hours and couldn't find any solution.
>>
>> p.s. my way was
>> 1. pragma Import(Stdcall,myProc,"myProc",Link_Name => "myDLL.dll");
>> result: undefined reference to "myDLL.dll"
>> 2. pragma Import(Stdcall,myProc,"myProc");

pragma Import (Stdcall, myProc);

should be enough.

>> result: undefined reference to myProc@8 (yes,it has to DWORD params)
>> and other attempts.

Do you link to the library? Either the DLL file must be specified or 
else the DLL import static library should. The former is given as-is to 
the linker the latter using -l switch. I presume you don't have the 
latter, so it is the former. E.g.

gnatmake ... -largs myDLL.dll

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


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

* Re: Ada,static link dll.(windows)
  2016-05-30  9:39   ` Dmitry A. Kazakov
@ 2016-05-30 10:48     ` George J
  2016-05-30 11:33       ` George J
  0 siblings, 1 reply; 5+ messages in thread
From: George J @ 2016-05-30 10:48 UTC (permalink / raw)


понедельник, 30 мая 2016 г., 12:39:44 UTC+3 пользователь Dmitry A. Kazakov написал:
> On 30/05/2016 11:09, George J wrote:
> > понедельник, 30 мая 2016 г., 12:08:09 UTC+3 пользователь George J написал:
> >> Hi ALL!So,today I've got a problem with dll:
> >> I have .dll (made with FASM) and I want to link it statically to
> >> my  Ada project. I've always made this way
> >> (https://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Windows)
> >> by dinamically linking. So I want to link my dll statically. I've spent
> >> 6 hours and couldn't find any solution.
> >>
> >> p.s. my way was
> >> 1. pragma Import(Stdcall,myProc,"myProc",Link_Name => "myDLL.dll");
> >> result: undefined reference to "myDLL.dll"
> >> 2. pragma Import(Stdcall,myProc,"myProc");
> 
> pragma Import (Stdcall, myProc);
> 
> should be enough.
> 
> >> result: undefined reference to myProc@8 (yes,it has to DWORD params)
> >> and other attempts.
> 
> Do you link to the library? Either the DLL file must be specified or 
> else the DLL import static library should. The former is given as-is to 
> the linker the latter using -l switch. I presume you don't have the 
> latter, so it is the former. E.g.
> 
> gnatmake ... -largs myDLL.dll
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
Thanks for reply!
I'm trying all this time to do some:
1. ...(.gpr proj file)
-------------------------
package Linker is

      case Win32Ada_Build is

         when "default" =>
            for Default_Switches ("ada") use ("-g", "-largs myDLL.dll");
            for Linker_Options use ();

         when "relocatable" =>
            for Default_Switches ("ada") use ("-g");
      end case;
   end Linker;
--------------------
or
2.
-------------------
package Linker is

      case Win32Ada_Build is

         when "default" =>
            for Default_Switches ("ada") use ("-g", "-l myDLL.dll");
            for Linker_Options use ();

         when "relocatable" =>
            for Default_Switches ("ada") use ("-g");
      end case;
   end Linker;
-----------------------

the result is :c:/gnat/2015/bin/../libexec/gcc/i686-pc-mingw32/4.9.3/ld.exe:
 cannot find -largs myDLL.dll (or -l myDLL.dll)
--
Although I pasted fullpath for dll, but it doesn't work. What I'm doing wrong?

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

* Re: Ada,static link dll.(windows)
  2016-05-30 10:48     ` George J
@ 2016-05-30 11:33       ` George J
  0 siblings, 0 replies; 5+ messages in thread
From: George J @ 2016-05-30 11:33 UTC (permalink / raw)


понедельник, 30 мая 2016 г., 13:48:47 UTC+3 пользователь George J написал:
> понедельник, 30 мая 2016 г., 12:39:44 UTC+3 пользователь Dmitry A. Kazakov написал:
> > On 30/05/2016 11:09, George J wrote:
> > > понедельник, 30 мая 2016 г., 12:08:09 UTC+3 пользователь George J написал:
> > >> Hi ALL!So,today I've got a problem with dll:
> > >> I have .dll (made with FASM) and I want to link it statically to
> > >> my  Ada project. I've always made this way
> > >> (https://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Windows)
> > >> by dinamically linking. So I want to link my dll statically. I've spent
> > >> 6 hours and couldn't find any solution.
> > >>
> > >> p.s. my way was
> > >> 1. pragma Import(Stdcall,myProc,"myProc",Link_Name => "myDLL.dll");
> > >> result: undefined reference to "myDLL.dll"
> > >> 2. pragma Import(Stdcall,myProc,"myProc");
> > 
> > pragma Import (Stdcall, myProc);
> > 
> > should be enough.
> > 
> > >> result: undefined reference to myProc@8 (yes,it has to DWORD params)
> > >> and other attempts.
> > 
> > Do you link to the library? Either the DLL file must be specified or 
> > else the DLL import static library should. The former is given as-is to 
> > the linker the latter using -l switch. I presume you don't have the 
> > latter, so it is the former. E.g.
> > 
> > gnatmake ... -largs myDLL.dll
> > 
> > -- 
> > Regards,
> > Dmitry A. Kazakov
> > http://www.dmitry-kazakov.de
> Thanks for reply!
> I'm trying all this time to do some:
> 1. ...(.gpr proj file)
> -------------------------
> package Linker is
> 
>       case Win32Ada_Build is
> 
>          when "default" =>
>             for Default_Switches ("ada") use ("-g", "-largs myDLL.dll");
>             for Linker_Options use ();
> 
>          when "relocatable" =>
>             for Default_Switches ("ada") use ("-g");
>       end case;
>    end Linker;
> --------------------
> or
> 2.
> -------------------
> package Linker is
> 
>       case Win32Ada_Build is
> 
>          when "default" =>
>             for Default_Switches ("ada") use ("-g", "-l myDLL.dll");
>             for Linker_Options use ();
> 
>          when "relocatable" =>
>             for Default_Switches ("ada") use ("-g");
>       end case;
>    end Linker;
> -----------------------
> 
> the result is :c:/gnat/2015/bin/../libexec/gcc/i686-pc-mingw32/4.9.3/ld.exe:
>  cannot find -largs myDLL.dll (or -l myDLL.dll)
> --
> Although I pasted fullpath for dll, but it doesn't work. What I'm doing wrong?

Thanks Dmitry!I've got! The result is:
(part of gpr project file)
--------------------------
   package Linker is

      case Win32Ada_Build is

         when "default" =>
            for Default_Switches ("ada") use ("-g", "-lmyDLL");
            for Linker_Options use ();

         when "relocatable" =>
            for Default_Switches ("ada") use ("-g");
      end case;
   end Linker;
----------------------
Thanks!
And warning appears:
"Warning: resolving _myProc@8 by linking to _myProc
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups"

I think it's not dangerous.


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

end of thread, other threads:[~2016-05-30 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30  9:08 Ada,static link dll.(windows) George J
2016-05-30  9:09 ` George J
2016-05-30  9:39   ` Dmitry A. Kazakov
2016-05-30 10:48     ` George J
2016-05-30 11:33       ` George J

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