OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 1:33 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How do I use different C++ header files in my kernel code?
PostPosted: Tue Jul 30, 2019 10:01 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Hey.
In my kernel I wanted to use some header files from C++, for example vector. C++ compiles, but the ld linker throws an error.
Compile a kernel so:
Code:
nasm -f elf32 ./source/kernel.asm -o kasm.o
g++ -m32 -std=c++11 -c ./source/kernel.cpp -o kc.o
ld -m elf_i386 -T link.ld -o kernel-0 kasm.o kc.o

Please help.


Top
 Profile  
 
 Post subject: Re: How do I use different C++ header files in my kernel cod
PostPosted: Tue Jul 30, 2019 10:18 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
You can't, remember this is your OS, there are no standard libraries, nothing.
You have to write it yourself or port a third party one, I prefer the former.

Related:
https://wiki.osdev.org/C_Library
https://wiki.osdev.org/Creating_a_C_Library
https://wiki.osdev.org/C%2B%2B#Full_C.2B.2B_Runtime_Support_Using_libgcc_And_libsupc.2B.2B
https://wiki.osdev.org/How_kernel,_compiler,_and_C_library_work_together#C_Library

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: How do I use different C++ header files in my kernel cod
PostPosted: Tue Jul 30, 2019 2:25 pm 
Offline

Joined: Sun Jul 14, 2019 4:27 pm
Posts: 22
If you want to use something like vector in a kernel you need to:

1. Implement paging

2. Build an allocator against your paging

3. Tie that in as a custom allocator against vector or implement your own vector class


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: DotBot [Bot], Google [Bot] and 102 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