comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Building an encapsulated library that uses GNAT sockets under Windows
Date: Fri, 22 Apr 2016 10:23:01 +0200
Date: 2016-04-22T10:23:01+02:00	[thread overview]
Message-ID: <nfcn1v$1tc2$1@gioia.aioe.org> (raw)
In-Reply-To: 58a4942a-452a-4f32-b39b-f8f1fdbfe9fb@googlegroups.com

On 22/04/2016 09:58, ahlan.marriott@gmail.com wrote:
> On Thursday, 21 April 2016 15:00:04 UTC+2, Dmitry A. Kazakov  wrote:
>> It seems I finally found a way to build it. The solution is quite
>> perplexing. I would be glad if anybody could shed some light on it.
>>
>> An encapsulated library requires that -lws2_32 -lwsock32 appeared *both*
>> at the beginning and the end of the linker command line. Only then no
>> "undefined reference" messages appear.
>>
>> For this build this program:
>> --------------------------------------- gcc_wrapper.adb ---
>> with Ada.Command_Line;  use Ada.Command_Line;
>> with Ada.Exceptions;    use Ada.Exceptions;
>> with Ada.Text_IO;       use Ada.Text_IO;
>> with GNAT.OS_Lib;       use GNAT.OS_Lib;
>>
>> procedure GCC_Wrapper is
>>      Prefix : String_List :=
>>               (  new String'("-lwsock32"),
>>                  new String'("-lws2_32")
>>               );
>>      Options : String_List (1..Argument_Count);
>> begin
>>      for No in 1..Argument_Count loop
>>         Options (No) := new String'(Argument (No));
>>      end loop;
>>      declare
>>         List : String_List := Prefix & Options & Prefix;
>>      begin
>>         Put ("gcc.exe");
>>         for No in List'Range loop
>>            Put (" " & List (No).all);
>>         end loop;
>>         New_Line;
>>         Set_Exit_Status (Exit_Status (Spawn ("gcc.exe", List)));
>>      end;
>> exception
>>      when Error : others =>
>>         Put_Line
>>         (  Standard_Error,
>>            "Fault: " & Exception_Information (Error)
>>         );
>>         Set_Exit_Status (2);
>> end GCC_Wrapper;
>> --------------------------------------- gcc_wrapper.adb ---
>>
>> The project file must contain:
>>
>>      package Linker is
>>         for Driver use "<absolute-path-to>/gcc_wrapper.exe";
>>      end Linker;
>>
>> --
>> Regards,
>> Dmitry A. Kazakov
>> http://www.dmitry-kazakov.de
>
> Dear Dmitry,
>
> Is this perhaps the solution to my question "Using Gnat.Sockets in a Windows DLL" that I posted on 8-Dec-2015?

Yes, I think it is the same problem you reported. BTW, I built gprbuild 
from the latest Git sources. That did not fix the problem.

It looks really weird how GCC linker searches libraries under Windows. 
Not to mention its abysmal performance. It takes literally an hour to 
link an executable against 20-30 libraries.

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

  reply	other threads:[~2016-04-22  8:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 12:59 Building an encapsulated library that uses GNAT sockets under Windows Dmitry A. Kazakov
2016-04-22  7:58 ` ahlan.marriott
2016-04-22  8:23   ` Dmitry A. Kazakov [this message]
2016-04-23  9:20     ` Ahlan
2016-04-23  9:48       ` Dmitry A. Kazakov
2016-04-23 14:45         ` ahlan.marriott
2016-04-23 19:56           ` Dmitry A. Kazakov
2016-04-23 21:16             ` Simon Wright
2016-04-24  8:13               ` ahlan
2016-04-24  8:31                 ` Simon Wright
2016-04-26 19:43                   ` ahlan.marriott
2016-04-26 20:24                     ` Simon Wright
2016-04-26 22:32                     ` Jeffrey R. Carter
2016-04-27 22:16                     ` Randy Brukardt
2016-04-27 23:43                       ` Jeffrey R. Carter
2016-04-28  5:18                         ` J-P. Rosen
2016-04-28  5:59                           ` Jeffrey R. Carter
2016-05-09 22:32                             ` David Thompson
2016-04-28 20:23                         ` Randy Brukardt
2016-04-28 21:47                           ` Jeffrey R. Carter
2016-04-28  5:13                       ` J-P. Rosen
2016-04-26 20:20               ` Dmitry A. Kazakov
2016-04-26 21:23                 ` Simon Wright
2016-04-27  6:53                   ` Simon Wright
2016-04-27  7:25                     ` ahlan
2016-04-27  8:27                   ` Dmitry A. Kazakov
2016-04-27  9:59                     ` Simon Wright
replies disabled

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