Page 1 of 1
MeatySkeleton linking libc libraries
Posted: Wed May 03, 2017 11:49 pm
by MuchLearning
I've been stepping through the
MeatySkeleton Tutorial trying to understand each piece. I think I've got most of it down but I don't understand how the functions included in libc get linked when compiling the kernel.
I'm trying to recreate my own version of MeatySkeleton and when compiling the kernel I get 'undefined reference to ...' for anything from the libc directory.
Re: MeatySkeleton linking libc libraries
Posted: Wed May 03, 2017 11:53 pm
by iansjack
As the tutorial explains, if you want to use kind functions you need to create your own kind.
Re: MeatySkeleton linking libc libraries
Posted: Thu May 04, 2017 12:10 am
by MuchLearning
I have written headers and sources for the functions I am trying to use. With all headers installed my sysroot looks something like
Code: Select all
sysroot/
usr/
include/
stdio.h
terminal.h
lib/
libk.a
And the function I'm attempting to use, printf, comes from stdio.h. Does this mean libk.a is not getting created correctly? Is that where the sources are being linked from?
*Edit*: the libk.a archive does contain printf.libk.o so I'm not sure what is happening.
Re: MeatySkeleton linking libc libraries
Posted: Thu May 04, 2017 12:16 am
by StudlyCaps
Do you have -lk in your $LIBS variable in kernel/Makefile?
edit: Or more precisely, when you build the kernel, is gcc being passed -lk.
Re: MeatySkeleton linking libc libraries
Posted: Thu May 04, 2017 12:29 am
by MuchLearning
StudlyCaps wrote:Do you have -lk in your $LIBS variable in kernel/Makefile?
StudlyCaps you indeed have the studliest of caps. I must have missed this flag.
What does it do? I can't find anything about what it does anywhere.
Re: MeatySkeleton linking libc libraries
Posted: Thu May 04, 2017 12:41 am
by iansjack
It specifies that you want to link libk. You don't need to specify -lc as it is assumed.
In general, if you want to link libfoo you need -lfoo.
Re: MeatySkeleton linking libc libraries
Posted: Thu May 04, 2017 12:44 am
by StudlyCaps
You know I do
It tells the linker to link against a library named
lib
k.
edit: beaten!