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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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: Re: Using Gnat.Sockets in a Windows DLL Date: Tue, 8 Dec 2015 10:52:20 +0100 Organization: cbb software GmbH Message-ID: References: <220ee60f-3290-43d7-a097-cf90380d8bae@googlegroups.com> <26b16c1d-46d5-45ea-92a9-d321fea68716@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: bqgfK7NL3xTHnr0WRaLl4g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28702 Date: 2015-12-08T10:52:20+01:00 List-Id: On Mon, 7 Dec 2015 23:43:18 -0800 (PST), ahlan@marriott.org wrote: > If I have a one line test program that merely initialises a socket, ie > > My_Socket : GNAT.Sockets.Socket_Type; > begin > GNAT.Sockets.Create_Socket (My_Socket); > > then we have no problems building an executable but if we try and use the same > lines in a DLL we fail to find the external references. > Even if I explicitly put "Pragma Linker_Options ("-lws2_32"); > and place libws2_32.a in the Library_Dir Gnat still fails to satisfy the references. > > I am at a loss as to what I might be doing wrong and what I could try next. > This should be easy to solve, it probably has nothing to do with Gnat Sockets > but more to do with building DLLs using a GPR file. > > The following is our Gpr file > with "gtkada"; > with "win32ada"; > > project Monitor is > > package Naming is > for Casing use "mixedcase"; > end Naming; > > for Library_Name use "Monitor"; > for Shared_Library_Prefix use ""; > > for Source_Dirs use ("w:\source\ada\interfaces\monitor", > "w:\source\ada\interfaces", > "w:\source\ada\shared", > "w:\source\ada\open\shared"); > > for Library_Interface use ("Monitor_Interface"); > > for Object_Dir use "objects"; > > for Library_Options use ("-Lw:\product\windows", "resources.o"); > for Library_Dir use "w:\product\windows"; > for Library_Ali_Dir use "d:\binary\ada\interfaces\monitor"; > for Library_Kind use "dynamic"; > for Library_Standalone use "encapsulated"; > > package Pretty_Printer is > for Default_Switches ("ada") use ("-i2", "-M120", "-aL", "-A1", "-A4"); > end Pretty_Printer; > > package Builder is > for Default_Switches ("ada") use ("-s", "-g"); > end Builder; > > package Compiler is > for Default_Switches ("ada") use ("-O1", "-gnatQ", "-gnato", "-g", "-gnat12", > "-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120"); > end Compiler; > > package Binder is > for Default_Switches ("ada") use ("-E"); > end Binder; How about: package Linker is for Linker_Options use ("-lws2_32"); end Linker; P.S. You also can create projects for the external DLLs (like Windows DLL) you wanted to use. E.g. project w32n55 is for Externally_Built use "true"; for Source_Files use (); for Library_Dir use "where the DLL resides"; for Library_Name use "w32n55"; for Library_Kind use "dynamic"; end w32n55; Then you "with" this project in your project. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de