From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Building an encapsulated library that uses GNAT sockets under Windows Date: Thu, 21 Apr 2016 14:59:35 +0200 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: G7MXAklp0OAVRSdfcmpxRQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 X-Mozilla-News-Host: news://news.aioe.org X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:30217 Date: 2016-04-21T14:59:35+02:00 List-Id: 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 "/gcc_wrapper.exe"; end Linker; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de