comp.lang.ada
 help / color / mirror / Atom feed
* GNAT, portability between computers (win32)
@ 2016-08-10 14:17 George J
  2016-08-10 14:23 ` George J
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: George J @ 2016-08-10 14:17 UTC (permalink / raw)


Hi all!Today i've finished beta version of my project. And it was found out that i have to put much .dll files from "GNAT20XX\bin" with my project. And it is inexpedient.How may I link all necessary libraries (statically maybe) to use my exe independently on different computers with win32? Thanks!

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:17 GNAT, portability between computers (win32) George J
@ 2016-08-10 14:23 ` George J
  2016-08-10 14:43   ` Dmitry A. Kazakov
  2016-08-10 15:30 ` Aurele
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 25+ messages in thread
From: George J @ 2016-08-10 14:23 UTC (permalink / raw)


среда, 10 августа 2016 г., 17:17:10 UTC+3 пользователь George J написал:
> Hi all!Today i've finished beta version of my project. And it was found out that i have to put much .dll files from "GNAT20XX\bin" with my project. And it is inexpedient.How may I link all necessary libraries (statically maybe) to use my exe independently on different computers with win32? Thanks!

Oh,i see it's not clear explanation.. When i told "much .dll files from "GNAT20XX\bin" with my project" i meant with my Project.exe (libcairo-2.dll, libpng-3.dll and many others). Is there another way to make only one "exe"? with statically liked those libraries? Sorry, my english is very bad.

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:23 ` George J
@ 2016-08-10 14:43   ` Dmitry A. Kazakov
  2016-08-10 14:52     ` George J
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-10 14:43 UTC (permalink / raw)


On 10/08/2016 16:23, George J wrote:
> среда, 10 августа 2016 г., 17:17:10 UTC+3 пользователь George J написал:
>> Hi all!Today i've finished beta version of my project. And it was
>> found out that i have to put much .dll files from "GNAT20XX\bin" with my
>> project. And it is inexpedient.How may I link all necessary libraries
>> (statically maybe) to use my exe independently on different computers
>> with win32? Thanks!
>
> Oh,i see it's not clear explanation.. When i told "much .dll files
> from "GNAT20XX\bin" with my project" i meant with my Project.exe
> (libcairo-2.dll, libpng-3.dll and many others). Is there another way to
> make only one "exe"? with statically liked those libraries? Sorry, my
> english is very bad.

Even if you could link GTK statically, which, when possible, would not 
be easy, there remained a huge number of other files GTK requires: 
fonts, color themes etc.

You will need a proper installer if you wanted to distribute a GTK 
application under Windows.

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


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:43   ` Dmitry A. Kazakov
@ 2016-08-10 14:52     ` George J
  2016-08-10 16:07       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 25+ messages in thread
From: George J @ 2016-08-10 14:52 UTC (permalink / raw)


среда, 10 августа 2016 г., 17:44:50 UTC+3 пользователь Dmitry A. Kazakov написал:
> On 10/08/2016 16:23, George J wrote:
> > среда, 10 августа 2016 г., 17:17:10 UTC+3 пользователь George J написал:
> >> Hi all!Today i've finished beta version of my project. And it was
> >> found out that i have to put much .dll files from "GNAT20XX\bin" with my
> >> project. And it is inexpedient.How may I link all necessary libraries
> >> (statically maybe) to use my exe independently on different computers
> >> with win32? Thanks!
> >
> > Oh,i see it's not clear explanation.. When i told "much .dll files
> > from "GNAT20XX\bin" with my project" i meant with my Project.exe
> > (libcairo-2.dll, libpng-3.dll and many others). Is there another way to
> > make only one "exe"? with statically liked those libraries? Sorry, my
> > english is very bad.
> 
> Even if you could link GTK statically, which, when possible, would not 
> be easy, there remained a huge number of other files GTK requires: 
> fonts, color themes etc.
> 
> You will need a proper installer if you wanted to distribute a GTK 
> application under Windows.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Thanks Dmitry! I have to add some "pragma Linker_Options ("-llibcairo-2.dll");pragma Linker_Options ("libpng-3.dll");" Did I get it right?


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:17 GNAT, portability between computers (win32) George J
  2016-08-10 14:23 ` George J
@ 2016-08-10 15:30 ` Aurele
  2016-08-10 18:29   ` gautier_niouzes
  2016-08-10 16:55 ` George J
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-10 15:30 UTC (permalink / raw)


Hi George. Yes, unlike ObjectAda, Adacore's GNAT compiler does link some of its own DLLs with your the executable. You can determine which ones it uses by running the "Depends" application:

http://www.dependencywalker.com/

This application will list all the Microsoft and GNAT DLL used by your application. The Microsoft DLLs are a non-issue. You're then have to do a search on your development computer to locate the required GNAT DLLs. Just copy those to your target (place them in the same directory as your executable).


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:52     ` George J
@ 2016-08-10 16:07       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-10 16:07 UTC (permalink / raw)


On 2016-08-10 16:52, George J wrote:

> I have to add some "pragma Linker_Options ("-llibcairo-2.dll");pragma
> Linker_Options ("libpng-3.dll");" Did I get it right?

No, these are added automatically when you "with" gtkada.gpr in your 
project.

There is "static" linking scenario variable for GtkAda, but that will 
have only effect on GtkAda, not GTK.

You need roughly the following files:

bin/libatk-1.0-0.dll
     ...
     zlib1.dll
   + your application

etc/fonts
    /gtk-03.0
    /pango

lib/gtk-3.0

share/glib-2.0
      /icons/Adwaita
            /hicolor ?
      /locale
      /themes/Adwaita
             /Default
             /Emacs ?

Some try and error is needed to get all right.

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


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:17 GNAT, portability between computers (win32) George J
  2016-08-10 14:23 ` George J
  2016-08-10 15:30 ` Aurele
@ 2016-08-10 16:55 ` George J
  2016-08-10 17:16 ` George J
  2016-08-11  9:53 ` Aurele
  4 siblings, 0 replies; 25+ messages in thread
From: George J @ 2016-08-10 16:55 UTC (permalink / raw)


Aurele,thanks for the link!it will be very helpful!
Dmitry,thanks!i've got!i'll do this.


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:17 GNAT, portability between computers (win32) George J
                   ` (2 preceding siblings ...)
  2016-08-10 16:55 ` George J
@ 2016-08-10 17:16 ` George J
  2016-08-11  9:53 ` Aurele
  4 siblings, 0 replies; 25+ messages in thread
From: George J @ 2016-08-10 17:16 UTC (permalink / raw)


среда, 10 августа 2016 г., 17:17:10 UTC+3 пользователь George J написал:
> Hi all!Today i've finished beta version of my project. And it was found out that i have to put much .dll files from "GNAT20XX\bin" with my project. And it is inexpedient.How may I link all necessary libraries (statically maybe) to use my exe independently on different computers with win32? Thanks!

I've found some answers this : https://groups.google.com/forum/#!topic/comp.lang.ada/_Cta-HgtTKM
Thanks to all!

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 15:30 ` Aurele
@ 2016-08-10 18:29   ` gautier_niouzes
  2016-08-10 20:44     ` Aurele
  2016-08-11 14:47     ` George J
  0 siblings, 2 replies; 25+ messages in thread
From: gautier_niouzes @ 2016-08-10 18:29 UTC (permalink / raw)


Le mercredi 10 août 2016 17:30:48 UTC+2, Aurele a écrit :
> Hi George. Yes, unlike ObjectAda, Adacore's GNAT compiler does link some of its own DLLs with your the executable.

It would be interesting to see what is triggering this dependency in your case, but in general GNAT does *not* link its own DLLs. I have many Windows applications (both corporate & open-source software) where the .exe is the only file needed to run on a target machine that never saw GNAT, nor its shadow ;-) ...
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont/

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 18:29   ` gautier_niouzes
@ 2016-08-10 20:44     ` Aurele
  2016-08-11  5:08       ` gautier_niouzes
  2016-08-11 14:47     ` George J
  1 sibling, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-10 20:44 UTC (permalink / raw)


Hi Gautier, I ran into the problem described above.  In fact, if you run the application tool I linked above which resolves all the dependencies, you should see that a compiled GNAT application (.exe) can indeed depend on GNAT specific DLLs. But I wonder if this problem could have to do with compiling on a commercial GNAT version versus using the free a version?

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 20:44     ` Aurele
@ 2016-08-11  5:08       ` gautier_niouzes
  0 siblings, 0 replies; 25+ messages in thread
From: gautier_niouzes @ 2016-08-11  5:08 UTC (permalink / raw)


Le mercredi 10 août 2016 22:44:51 UTC+2, Aurele a écrit :
> Hi Gautier, I ran into the problem described above.  In fact, if you run the application tool I linked above which resolves all the dependencies, you should see that a compiled GNAT application (.exe) can indeed depend on GNAT specific DLLs. But I wonder if this problem could have to do with compiling on a commercial GNAT version versus using the free a version?

Never saw this issue, neither with GNAT GPL, nor with MinGW (cannot say for GNAT Pro).
You can check dependencies with TeXCAD ( http://texcad.sf.net ) or AZip ( http://azip.sf.net ). One is compiled with GPL and the other one with any of GPL or MinGW. In the 3 cases, Dependency Walker lists the following:

    ADVAPI32.DLL
    COMCTL32.DLL
    COMDLG32.DLL
    GDI32.DLL
    KERNEL32.DLL
    MSVCRT32.DLL
    OLE32.DLL
    OLEAUT32.DLL
    SHELL32.DLL
    USER32.DLL

All are located in %windir%\system32, except COMCTL32.DLL which is in special subdirectory of %windir%.
IIRC, COMCTL32.DLL is installed by default since Windows 98, but since it a post-early-1990's addition, it was never allowed to be in the system32 directory 
(I'm testing here on Windows 7 but I guess someone with Windows 8 or 10 would see the same.
Funny, isn't it ?
_________________________ 
Gautier's Ada programming 
http://gautiersblog.blogspot.com/search/label/Ada 
NB: follow the above link for a valid e-mail address 


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

* Re: GNAT, portability between computers (win32)
  2016-08-10 14:17 GNAT, portability between computers (win32) George J
                   ` (3 preceding siblings ...)
  2016-08-10 17:16 ` George J
@ 2016-08-11  9:53 ` Aurele
  2016-08-11 10:11   ` Pascal Obry
  4 siblings, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-11  9:53 UTC (permalink / raw)


Hey Gautier. if you run Dependency Walker on AGL32.DLL (the file I already sent you) you'll see that it depends on at least two non-Microsoft external files: namely LIBGNAT-2016.DLL and LIBGNARL-2016.DLL  Older versions of GNAT may have different names...  Anyway, all I'm saying is that I've encountered a similar problem as that expressed by George above.  

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

* Re: GNAT, portability between computers (win32)
  2016-08-11  9:53 ` Aurele
@ 2016-08-11 10:11   ` Pascal Obry
  2016-08-11 10:17     ` Aurele
  0 siblings, 1 reply; 25+ messages in thread
From: Pascal Obry @ 2016-08-11 10:11 UTC (permalink / raw)


Le jeudi 11 août 2016 à 02:53 -0700, Aurele a écrit :
> Hey Gautier. if you run Dependency Walker on AGL32.DLL (the file I
> already sent you) you'll see that it depends on at least two non-
> Microsoft external files: namely LIBGNAT-2016.DLL and LIBGNARL-
> 2016.DLL  Older versions of GNAT may have different names...  Anyway,
> all I'm saying is that I've encountered a similar problem as that
> expressed by George above.  

You just need to link statically with the GNAT runtime to avoid those
dependencies.

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: GNAT, portability between computers (win32)
  2016-08-11 10:11   ` Pascal Obry
@ 2016-08-11 10:17     ` Aurele
  2016-08-11 13:40       ` Pascal Obry
  0 siblings, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-11 10:17 UTC (permalink / raw)


On Thursday, August 11, 2016 at 6:11:58 AM UTC-4, Pascal Obry wrote:
> You just need to link statically with the GNAT runtime to avoid those
> dependencies.

Can you be a bit more specific? What linker switch are you talking about?


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 10:17     ` Aurele
@ 2016-08-11 13:40       ` Pascal Obry
  2016-08-11 14:53         ` Aurele
  0 siblings, 1 reply; 25+ messages in thread
From: Pascal Obry @ 2016-08-11 13:40 UTC (permalink / raw)


Le jeudi 11 août 2016 à 03:17 -0700, Aurele a écrit :
> Can you be a bit more specific? What linker switch are you talking
> about?

The GNAT User's Guide can be more specific:

https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#binding-with-gnatbind

Look for -static in section 4.5.2.

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: GNAT, portability between computers (win32)
  2016-08-10 18:29   ` gautier_niouzes
  2016-08-10 20:44     ` Aurele
@ 2016-08-11 14:47     ` George J
  2016-08-11 14:50       ` George J
  1 sibling, 1 reply; 25+ messages in thread
From: George J @ 2016-08-11 14:47 UTC (permalink / raw)


среда, 10 августа 2016 г., 21:29:17 UTC+3 пользователь gautier...@hotmail.com написал:
> Le mercredi 10 août 2016 17:30:48 UTC+2, Aurele a écrit :
> > Hi George. Yes, unlike ObjectAda, Adacore's GNAT compiler does link some of its own DLLs with your the executable.
> 
> It would be interesting to see what is triggering this dependency in your case, but in general GNAT does *not* link its own DLLs. I have many Windows applications (both corporate & open-source software) where the .exe is the only file needed to run on a target machine that never saw GNAT, nor its shadow ;-) ...
> _________________________ 
> Gautier's Ada programming 
> http://sf.net/users/gdemont/

Hi all!Hi Gauter! Im using GNAT2016 and GTK gui in my app. Yesterday i've found out all gtk dlls which are necessary to run my program without problems - 21 dll (from libcairo-2 to zlib1).  So I've decided to link them one by one and check out,whether my .exe can run on the comp which has no gnat and gtk installed files. The first was libcairo-2. (linker =>  llibcairo-2,  binder  =>  -static) That's part of my .gpr :
---------------------------
 package Linker is
      case Library_Type is
         when "static" =>
            case Win32Ada_Build is
               when "default" =>
                  for Default_Switches ("ada") use ("-llibcairo-2", "-mwindows");
               when "relocatable" =>
                  for Default_Switches ("ada") use ("-g");
            end case;
         when "relocatable" =>
            for Default_Switches ("ada") use ("-g");
      end case;
   end Linker;

   package Binder is
      case Library_Type is
         when "static" =>
            case Win32Ada_Build is
               when "default" =>
                  for Default_Switches ("ada") use ("-static");
               when "relocatable" =>
            end case;
         when "relocatable" =>
      end case;
   end Binder;
------------------------------------
So when i run my .exe on the other comp it shows me the same error : "The program couldn't be started cause of libcairo-2.dll doesn't exists". Could smb tell me,where I'm wrong?


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 14:47     ` George J
@ 2016-08-11 14:50       ` George J
  2016-08-11 16:03         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 25+ messages in thread
From: George J @ 2016-08-11 14:50 UTC (permalink / raw)


четверг, 11 августа 2016 г., 17:47:25 UTC+3 пользователь George J написал:
> среда, 10 августа 2016 г., 21:29:17 UTC+3 пользователь gautier...@hotmail.com написал:
> > Le mercredi 10 août 2016 17:30:48 UTC+2, Aurele a écrit :
> > > Hi George. Yes, unlike ObjectAda, Adacore's GNAT compiler does link some of its own DLLs with your the executable.
> > 
> > It would be interesting to see what is triggering this dependency in your case, but in general GNAT does *not* link its own DLLs. I have many Windows applications (both corporate & open-source software) where the .exe is the only file needed to run on a target machine that never saw GNAT, nor its shadow ;-) ...
> > _________________________ 
> > Gautier's Ada programming 
> > http://sf.net/users/gdemont/
> 
> Hi all!Hi Gauter! Im using GNAT2016 and GTK gui in my app. Yesterday i've found out all gtk dlls which are necessary to run my program without problems - 21 dll (from libcairo-2 to zlib1).  So I've decided to link them one by one and check out,whether my .exe can run on the comp which has no gnat and gtk installed files. The first was libcairo-2. (linker =>  llibcairo-2,  binder  =>  -static) That's part of my .gpr :
> ---------------------------
>  package Linker is
>       case Library_Type is
>          when "static" =>
>             case Win32Ada_Build is
>                when "default" =>
>                   for Default_Switches ("ada") use ("-llibcairo-2", "-mwindows");
>                when "relocatable" =>
>                   for Default_Switches ("ada") use ("-g");
>             end case;
>          when "relocatable" =>
>             for Default_Switches ("ada") use ("-g");
>       end case;
>    end Linker;
> 
>    package Binder is
>       case Library_Type is
>          when "static" =>
>             case Win32Ada_Build is
>                when "default" =>
>                   for Default_Switches ("ada") use ("-static");
>                when "relocatable" =>
>             end case;
>          when "relocatable" =>
>       end case;
>    end Binder;
> ------------------------------------
> So when i run my .exe on the other comp it shows me the same error : "The program couldn't be started cause of libcairo-2.dll doesn't exists". Could smb tell me,where I'm wrong?

Oh,excuse me,Gautier, of course!.


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 13:40       ` Pascal Obry
@ 2016-08-11 14:53         ` Aurele
  2016-08-11 16:11           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-11 14:53 UTC (permalink / raw)


> Look for -static in section 4.5.2.

Thanks for the specifics. Unfortunately, GPS has no such switch and entering it explicitly in the build file does nothing.  By the way, I forgot to mention I'm building an Ada "Dynamic" library or DLL, so maybe that's way it depends on these GNAT specific external DLLs. No idea why your EXE would also depend on such George because as Gautier already mentioned, none of my EXEs have such dependencies :?


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 14:50       ` George J
@ 2016-08-11 16:03         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-11 16:03 UTC (permalink / raw)


On 2016-08-11 16:50, George J wrote:

>> So when i run my .exe on the other comp it shows me the same error
>> :  "The program couldn't be started cause of libcairo-2.dll doesn't
>> exists". Could smb tell me,where I'm wrong?

To link statically you must do to static libraries. A static Cairo 
library will have name like libcairo-2.a.

The switch -static influences the application being built not the 
libraries it references. E.g. KERNEL32.dll will be linked as a DLL, 
there is no static library. Same goes for GTK. There are no static GTK 
libraries under Windows like there is no KERNEL32 static library. Unless 
you manage to build static GTK libraries from sources yourself.

But that would be pretty much pointless exercise anyway. GTK needs lots 
of non-executable files to start. It will crash and/or spit a pile of 
messages if you don't have these files, even if all libraries are there.

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

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

* Re: GNAT, portability between computers (win32)
  2016-08-11 14:53         ` Aurele
@ 2016-08-11 16:11           ` Dmitry A. Kazakov
  2016-08-11 16:41             ` Aurele
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-11 16:11 UTC (permalink / raw)


On 2016-08-11 16:53, Aurele wrote:
>> Look for -static in section 4.5.2.
>
> Thanks for the specifics. Unfortunately, GPS has no such switch and
> entering it explicitly in the build file does nothing. By the way, I
> forgot to mention I'm building an Ada "Dynamic" library or DLL, so maybe
> that's way it depends on these GNAT specific external DLLs. No idea why
> your EXE would also depend on such George because as Gautier already
> mentioned, none of my EXEs have such dependencies :?

A DLL that includes GNAT run-time and thus does not depend on GNAT DLLs 
is called stand-alone. See

https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html#stand-alone-library-projects

You must have

   for Library_Standalone use "encapsulated";

in your library project.

P.S. It does not work well for Windows, see another discussion thread.

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

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

* Re: GNAT, portability between computers (win32)
  2016-08-11 16:11           ` Dmitry A. Kazakov
@ 2016-08-11 16:41             ` Aurele
  2016-08-11 17:23               ` Dmitry A. Kazakov
  0 siblings, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-11 16:41 UTC (permalink / raw)


> A DLL that includes GNAT run-time and thus does not depend on GNAT DLLs 
> is called stand-alone. You must have
> 
>    for Library_Standalone use "encapsulated";
> 
> in your library project.
> 

That did the trick.  Thanks Dmitry !!!

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

* Re: GNAT, portability between computers (win32)
  2016-08-11 16:41             ` Aurele
@ 2016-08-11 17:23               ` Dmitry A. Kazakov
  2016-08-11 18:12                 ` Aurele
  2016-08-11 19:42                 ` Aurele
  0 siblings, 2 replies; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-11 17:23 UTC (permalink / raw)


On 2016-08-11 18:41, Aurele wrote:
>> A DLL that includes GNAT run-time and thus does not depend on GNAT DLLs
>> is called stand-alone. You must have
>>
>>    for Library_Standalone use "encapsulated";
>>
>> in your library project.
>>
> That did the trick.  Thanks Dmitry !!!

Don't rush. It might freeze upon loading. If it does, which is most 
likely the case when the library does anything beyond trivial 
computations. Then

1. add for Library_Auto_Init use "false";

2. make sure that gnatbind is invoked without -a switch

3. call <libname>init before first use of the library. E.g. if the 
library name is foo then

procedure Init_My_Library;
pragma Import ("C", Init_My_Library, "fooinit");

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


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 17:23               ` Dmitry A. Kazakov
@ 2016-08-11 18:12                 ` Aurele
  2016-08-11 20:53                   ` Dmitry A. Kazakov
  2016-08-11 19:42                 ` Aurele
  1 sibling, 1 reply; 25+ messages in thread
From: Aurele @ 2016-08-11 18:12 UTC (permalink / raw)


Actually Dmitry, I'm using the auto init (true) feature and everything works great with no external GNAT dependencies.  Adding the "encapsulated" switch solved my problem and no load freeze when called from the test program.  Again, thank you !

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

* Re: GNAT, portability between computers (win32)
  2016-08-11 17:23               ` Dmitry A. Kazakov
  2016-08-11 18:12                 ` Aurele
@ 2016-08-11 19:42                 ` Aurele
  1 sibling, 0 replies; 25+ messages in thread
From: Aurele @ 2016-08-11 19:42 UTC (permalink / raw)


> Don't rush. It might freeze upon loading. If it does, which is most 
> likely the case when the library does anything beyond trivial 
> computations. Then
> 
> 1. add for Library_Auto_Init use "false";
> 
> 2. make sure that gnatbind is invoked without -a switch
> 
> 3. call <libname>init before first use of the library. E.g. if the 
> library name is foo then
> 
> procedure Init_My_Library;
> pragma Import ("C", Init_My_Library, "fooinit");

Some more info on how I finally got the DLL working.
 
1. I used: for Library_Standalone use "encapsulated";
2. I used: Library_Auto_Init use "true";
3. Must NOT use the "-shared" binder switch on either the DLL or the calling application.  Using the -shared switch cause the DLL/app to freeze.

Thanks for your input Dmitry o7
Aurele


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

* Re: GNAT, portability between computers (win32)
  2016-08-11 18:12                 ` Aurele
@ 2016-08-11 20:53                   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 25+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-11 20:53 UTC (permalink / raw)


On 2016-08-11 20:12, Aurele wrote:
> Actually Dmitry, I'm using the auto init (true) feature and
> everything  works great with no external GNAT dependencies.

Yes, the problem is that if your DLL has library-level tasks or timed 
entry calls automatic initialization will deadlock. The offending call 
is Lock_RTS. If you look at the b__libraryname.adb file generated by 
gprbuild you will find there calls to the system procedures doing 
library initialization. If any of them calls Lock_RTS in its body, the 
DLL will freeze your program.

It hit me hard recently. Luckily I could go with manual initialization. 
It is quite frustrating that GNAT does not support DLLs with full Ada.

P.S. There is no need to lock RTS under Windows because threading is 
already locked when DLL is being loaded.

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

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

end of thread, other threads:[~2016-08-11 20:53 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10 14:17 GNAT, portability between computers (win32) George J
2016-08-10 14:23 ` George J
2016-08-10 14:43   ` Dmitry A. Kazakov
2016-08-10 14:52     ` George J
2016-08-10 16:07       ` Dmitry A. Kazakov
2016-08-10 15:30 ` Aurele
2016-08-10 18:29   ` gautier_niouzes
2016-08-10 20:44     ` Aurele
2016-08-11  5:08       ` gautier_niouzes
2016-08-11 14:47     ` George J
2016-08-11 14:50       ` George J
2016-08-11 16:03         ` Dmitry A. Kazakov
2016-08-10 16:55 ` George J
2016-08-10 17:16 ` George J
2016-08-11  9:53 ` Aurele
2016-08-11 10:11   ` Pascal Obry
2016-08-11 10:17     ` Aurele
2016-08-11 13:40       ` Pascal Obry
2016-08-11 14:53         ` Aurele
2016-08-11 16:11           ` Dmitry A. Kazakov
2016-08-11 16:41             ` Aurele
2016-08-11 17:23               ` Dmitry A. Kazakov
2016-08-11 18:12                 ` Aurele
2016-08-11 20:53                   ` Dmitry A. Kazakov
2016-08-11 19:42                 ` Aurele

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