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!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: undefined reference while calling an imported c function as procedure in ada Date: Fri, 25 May 2018 18:41:47 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ecx7ngVfOlDBfOfUjEFBYQw1dCenKPJjFrjVLkWJJCvdT4fiay Cancel-Lock: sha1:04/7oX783qPfSFHzuue26D60cXc= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader02.eternal-september.org comp.lang.ada:52676 Date: 2018-05-25T18:41:47+03:00 List-Id: On 18-05-25 16:52 , boonflies@gmail.com wrote: > We receive, undefined reference to `CLIENT_CR', while linking. > > The code we are building > In Tftp.h > > `void CLIENT_CR > ( > CREATE_INFO * CreateInfo, > ID * SessionId, > RESULT * Result > );` > > 2. In Tftp.ads > `procedure CLIENT_CR( CreateInfo : in Tpkg.CREATE_INFO; > SessionId : out Tpkg.ID; > Result : out RESULT ); > > pragma Import (C, CLIENT_CR, "CLIENT_CR");` > > 3. In main.adb > `#With TFTP; > > ... > TFTP.CLIENT_CR(INFO,ID,RESULT)` Apply the "nm" tool to the object (.o) file compiled from Tftp.c (probably named Tftp.o) to see the link-name that the C (or C++?) compiler assigns to the CLIENT_CR subprogram. Use that link-name in the pragma Import. Also, check that your linker command-line includes Tftp.o, or add a pragma Linker_Options naming that file to the Ada declaration. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .