* undefined reference while calling an imported c function as procedure in ada
@ 2018-05-25 13:52 boonflies
2018-05-25 14:31 ` Jacob Sparre Andersen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: boonflies @ 2018-05-25 13:52 UTC (permalink / raw)
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)`
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: undefined reference while calling an imported c function as procedure in ada
2018-05-25 13:52 undefined reference while calling an imported c function as procedure in ada boonflies
@ 2018-05-25 14:31 ` Jacob Sparre Andersen
2018-05-25 15:35 ` Dennis Lee Bieber
2018-05-25 15:41 ` Niklas Holsti
2 siblings, 0 replies; 4+ messages in thread
From: Jacob Sparre Andersen @ 2018-05-25 14:31 UTC (permalink / raw)
boonflies@gmail.com writes:
> We receive, undefined reference to `CLIENT_CR', while linking.
How did you do the linking then? How does your project file look? Or
the command line arguments to the compiler and/or linker?
Greetings,
Jacob
--
"Don't get me wrong, perl is an OK operating system, but it
lacks a lightweight scripting language."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: undefined reference while calling an imported c function as procedure in ada
2018-05-25 13:52 undefined reference while calling an imported c function as procedure in ada boonflies
2018-05-25 14:31 ` Jacob Sparre Andersen
@ 2018-05-25 15:35 ` Dennis Lee Bieber
2018-05-25 15:41 ` Niklas Holsti
2 siblings, 0 replies; 4+ messages in thread
From: Dennis Lee Bieber @ 2018-05-25 15:35 UTC (permalink / raw)
On Fri, 25 May 2018 06:52:09 -0700 (PDT), boonflies@gmail.com declaimed the
following:
>
>`void CLIENT_CR
>(
> CREATE_INFO * CreateInfo,
> ID * SessionId,
> RESULT * Result
>);`
>
C prototype for a function...
>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");`
>
Ada prototype and specification that it maps to a C function...
>3. In main.adb
>`#With TFTP;
>
>...
>TFTP.CLIENT_CR(INFO,ID,RESULT)`
>
What's the # doing there?
What you have not provided is:
a) the actual C implementation of CLIENT_CR
b) the link command that uses whatever file contains said C implementation
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: undefined reference while calling an imported c function as procedure in ada
2018-05-25 13:52 undefined reference while calling an imported c function as procedure in ada boonflies
2018-05-25 14:31 ` Jacob Sparre Andersen
2018-05-25 15:35 ` Dennis Lee Bieber
@ 2018-05-25 15:41 ` Niklas Holsti
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Holsti @ 2018-05-25 15:41 UTC (permalink / raw)
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
. @ .
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-25 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-25 13:52 undefined reference while calling an imported c function as procedure in ada boonflies
2018-05-25 14:31 ` Jacob Sparre Andersen
2018-05-25 15:35 ` Dennis Lee Bieber
2018-05-25 15:41 ` Niklas Holsti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox