OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 3:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: MeatySkeleton linking libc libraries
PostPosted: Wed May 03, 2017 11:49 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 12, 2017 1:50 am
Posts: 26
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.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Wed May 03, 2017 11:53 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
As the tutorial explains, if you want to use kind functions you need to create your own kind.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Thu May 04, 2017 12:10 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 12, 2017 1:50 am
Posts: 26
I have written headers and sources for the functions I am trying to use. With all headers installed my sysroot looks something like
Code:
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.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Thu May 04, 2017 12:16 am 
Offline
Member
Member

Joined: Mon Jul 25, 2016 6:54 pm
Posts: 223
Location: Adelaide, Australia
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.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Thu May 04, 2017 12:29 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 12, 2017 1:50 am
Posts: 26
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.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Thu May 04, 2017 12:41 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: MeatySkeleton linking libc libraries
PostPosted: Thu May 04, 2017 12:44 am 
Offline
Member
Member

Joined: Mon Jul 25, 2016 6:54 pm
Posts: 223
Location: Adelaide, Australia
:D You know I do :wink:

It tells the linker to link against a library named libk.

edit: beaten!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 117 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group