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.
MeatySkeleton linking libc libraries
- MuchLearning
- Member
- Posts: 26
- Joined: Sun Feb 12, 2017 1:50 am
Re: MeatySkeleton linking libc libraries
As the tutorial explains, if you want to use kind functions you need to create your own kind.
- MuchLearning
- Member
- Posts: 26
- Joined: Sun Feb 12, 2017 1:50 am
Re: MeatySkeleton linking libc libraries
I have written headers and sources for the functions I am trying to use. With all headers installed my sysroot looks something like
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.
Code: Select all
sysroot/
usr/
include/
stdio.h
terminal.h
lib/
libk.a
*Edit*: the libk.a archive does contain printf.libk.o so I'm not sure what is happening.
-
- Member
- Posts: 232
- Joined: Mon Jul 25, 2016 6:54 pm
- Location: Adelaide, Australia
Re: MeatySkeleton linking libc libraries
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.
edit: Or more precisely, when you build the kernel, is gcc being passed -lk.
- MuchLearning
- Member
- Posts: 26
- Joined: Sun Feb 12, 2017 1:50 am
Re: MeatySkeleton linking libc libraries
StudlyCaps you indeed have the studliest of caps. I must have missed this flag.StudlyCaps wrote:Do you have -lk in your $LIBS variable in kernel/Makefile?
What does it do? I can't find anything about what it does anywhere.
Re: MeatySkeleton linking libc libraries
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.
In general, if you want to link libfoo you need -lfoo.
-
- Member
- Posts: 232
- Joined: Mon Jul 25, 2016 6:54 pm
- Location: Adelaide, Australia
Re: MeatySkeleton linking libc libraries
You know I do
It tells the linker to link against a library named libk.
edit: beaten!
It tells the linker to link against a library named libk.
edit: beaten!