OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Jun 02, 2024 3:41 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Error linking when including header files with barebones
PostPosted: Sun Oct 29, 2023 2:11 pm 
Offline

Joined: Sun Oct 29, 2023 1:24 pm
Posts: 1
Hello.

I've followed the barebones tutorial and got it to run in qemu. Now i'm trying to put some code in another file, test.{h,c}, but i get an error linking. There are no errors/messages compiling kernel.c. The error i get is:
Code:
/home/billy/opt/cross/lib/gcc/i686-elf/13.2.0/../../../../i686-elf/bin/ld: ../obj/kernel.o: in function `kernel_main':
kernel.c:(.text+0x445): undefined reference to `TestFunc'
collect2: error: ld returned 1 exit status

and the command i'm running is
Code:
i686-elf-gcc -T ../linker.ld -o ../bin/kernel.bin -ffreestanding -O2 -nostdlib ../obj//kernel.o -lgcc


Everything else is the same as the barebones tutorial.
Any help would be appreciated.

Thanks!


Top
 Profile  
 
 Post subject: Re: Error linking when including header files with barebones
PostPosted: Mon Oct 30, 2023 7:35 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
You are building a separate object file and then not including it when you link. You must include all object files in your final link.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 78 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