OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 11:32 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Some trouble adapting Meaty Skeleton to an existing project
PostPosted: Wed Apr 11, 2018 5:21 am 
Offline

Joined: Wed Mar 28, 2018 6:33 am
Posts: 5
Hi,

As the title states, I'm having some trouble adapting the Meaty Skeleton tutorial to my existing project.

Specifically, my problem comes with the libk, when it tries to call a function from the main kernel project (in this case, my equivalent of terminal_write()).
When linking, it says there's an undefined reference to that function, even though I have included the header.

I'm only getting this issue when I try to call the libk function (putchar) from the kernel itself (or libk functions that rely on it), though just including the header (stdio.h) without calling the function gives no issues.
Other functions in libk, which don't call anything from the kernel project (such as strlen) work fine.

Can anyone help me understand why I'm having this problem and maybe how I can solve it?


Top
 Profile  
 
 Post subject: Re: Some trouble adapting Meaty Skeleton to an existing proj
PostPosted: Wed Apr 11, 2018 11:24 am 
Offline
Member
Member

Joined: Fri Aug 19, 2016 10:28 pm
Posts: 360
I would suggest that you check whether you have that symbol defined in your kernel .o file with nm (or, objdump --syms, readelf -s, etc.). I suspect that you don't actually have it, or if you use C++, it may be a mangling issue (and then you need to use extern "C".)

The fact that you experience the issue only when you use an i/o routine from the library is normal. Libraries are object file packages/archives, such that any object file inside the library is only included by the linker when something inside it is actually used. The library probably has separate object file for the i/o routines inside it which carries the symbol dependency that your kernel fails to satisfy. You can view the contents of the library archive and the symbols in it with the nm command, or use the ar command to view the object file contents, extract individual object files (for testing purposes), etc.

Btw, header files have no play in this. They are entirely a compiler concern, and if your compilation is successful, they are irrelevant. (Well, generally speaking.)


Top
 Profile  
 
 Post subject: Re: Some trouble adapting Meaty Skeleton to an existing proj
PostPosted: Wed Apr 11, 2018 12:42 pm 
Offline

Joined: Wed Mar 28, 2018 6:33 am
Posts: 5
Adding extern "C" to my equivalent of terminal_write() solved my problem.

Thanks. I definitely hadn't thought of that.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], rdos and 206 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