comp.lang.ada
 help / color / mirror / Atom feed
* Having trouble with gnatlink
@ 2020-11-25 23:47 Pat Van Canada
  2020-11-26  8:24 ` Simon Wright
  0 siblings, 1 reply; 3+ messages in thread
From: Pat Van Canada @ 2020-11-25 23:47 UTC (permalink / raw)


Hi Everyone

I am fooling around a bit today. I used a null terminated record and passed it to printf in C code and now I am just fooling around with Jim Tcl.

I am having this error:
/usr/bin/ld: /usr/local/lib/libjim.a(jim.o): in function `Jim_AppendStrings':
/home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:2544: undefined reference to `__va_start'
/usr/bin/ld: /home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:2546: undefined reference to `__va_arg'
/usr/bin/ld: /usr/local/lib/libjim.a(jim.o): in function `JimRandDouble':
/home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:8155: undefined reference to `__floatundidf'
/usr/bin/ld: /usr/local/lib/libjim.a(jim.o): in function `Jim_SetResultFormatted':
/home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:15926: undefined reference to `__va_start'
/usr/bin/ld: /home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:15932: undefined reference to `__va_arg'
/usr/bin/ld: /home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:15937: undefined reference to `__va_arg'
/usr/bin/ld: /usr/local/lib/libjim.a(jim-aio.o): in function `JimAioOpenPtyCommand':
/home/patrick/JIM-DOODLING/jim2/jimtcl/jim-aio.c:2070: undefined reference to `openpty'
collect2: error: ld returned 1 exit status
gnatlink: error when calling /usr/bin/x86_64-linux-gnu-gcc-9  

Does gnatlink add libc by itself when there is C code being linked? I am assuming not but I don't know how to add it.

here is my build.sh

gcc-9 -c   call_printf_src.c  -I/usr/local/include
gcc-9 -c    pointer_test.adb c.ads
gnatlink -o pointer_test  -ljim -lm -ldl  -shared-libgcc pointer_test.ali  call_printf_src.o

I don't want to use gprbuild or anything that will hide what is happening. I want to learn a little more about compiling Ada.

Thanks for reading-Patrick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Having trouble with gnatlink
  2020-11-25 23:47 Having trouble with gnatlink Pat Van Canada
@ 2020-11-26  8:24 ` Simon Wright
  2020-11-26 13:27   ` Pat Van Canada
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Wright @ 2020-11-26  8:24 UTC (permalink / raw)


Pat Van Canada <google@spellingbeewinnars.org> writes:

> I am fooling around a bit today. I used a null terminated record and
> passed it to printf in C code and now I am just fooling around with
> Jim Tcl.
>
> I am having this error:
> /usr/bin/ld: /usr/local/lib/libjim.a(jim.o): in function `Jim_AppendStrings':
> /home/patrick/JIM-DOODLING/jim2/jimtcl/jim.c:2544: undefined reference
> to `__va_start'
[...]
> Does gnatlink add libc by itself when there is C code being linked? I
> am assuming not but I don't know how to add it.

Don't know, but see below

> here is my build.sh
>
> gcc-9 -c   call_printf_src.c  -I/usr/local/include
> gcc-9 -c    pointer_test.adb c.ads

You should have a gnatbind call here to generate the actual main program
& elaboration code.

> gnatlink -o pointer_test -ljim -lm -ldl -shared-libgcc
> pointer_test.ali call_printf_src.o

gnatlink --help suggests that pointer_test.ali and call_printf_src.o
should come before -ljim etc.

And if you want libc, add -lc at the end?

> I don't want to use gprbuild or anything that will hide what is
> happening. I want to learn a little more about compiling Ada.

Use -v or -v -v to see what gnatlink is actually doing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Having trouble with gnatlink
  2020-11-26  8:24 ` Simon Wright
@ 2020-11-26 13:27   ` Pat Van Canada
  0 siblings, 0 replies; 3+ messages in thread
From: Pat Van Canada @ 2020-11-26 13:27 UTC (permalink / raw)


Thanks very much Simon

I have it working now. Here is the build.sh. I am sorry I deleted the gnatbind part the last time when I tried to delete the unneeded echo calls.:
 rm  *.ali *.o
echo  "---------------->compiling c code"
 gcc-9 -c call_printf_src.c 
echo  "---------------->compiling main ada code"
 gcc-9 -c pointer_test.adb c.ads
echo  "---------------->binding ada code"
 gnatbind -x pointer_test.ali 
echo  "---------------->linking ada and c"
 gnatlink -o pointer_test /usr/local/lib/libjim.so.0.77 \
             pointer_test.ali  call_printf_src.o

I don't have -L/usr/local/lib -ljim working as it should but I can figure that out later.

Thanks again-Patrick



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-26 13:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 23:47 Having trouble with gnatlink Pat Van Canada
2020-11-26  8:24 ` Simon Wright
2020-11-26 13:27   ` Pat Van Canada

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