OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 8:15 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: undefined reference to `vtable for __cxxabiv1::__class_type_
PostPosted: Wed Apr 12, 2017 7:41 pm 
Offline

Joined: Wed Apr 12, 2017 7:32 pm
Posts: 3
Hello Guys,

I am writing a kernel for like 2 months now and converted the project to C++ but virtual function do not seem to work for me.
I have CPPFLAGS?=-O2 -g -fno-exceptions -fno-rtti and also defined in a .cpp file the extern "C" void __cxa_pure_virtual().
Still getting this:
i686-elf-g++ --sysroot=/home/geri/workspace/bodos/src/../sysroot -isystem=/usr/include -T arch/i386/linker.ld -o bodos.kernel -D__is_kernel -Iinclude -ffreestanding -Wall -Wextra arch/i386/crti.o arch/i386/crtbegin.o arch/i386/boot.o arch/i386/tty.o arch/i386/cursor.o arch/i386/io.o arch/i386/serialport.o arch/i386/gdt.o arch/i386/init.o arch/i386/gdt_load.o arch/i386/isr.o arch/i386/isr_irq.o arch/i386/idt.o arch/i386/interrupt_x86.o arch/i386/irq.o arch/i386/timer.o arch/i386/keyboard.o arch/i386/paging.o arch/i386/sched/ctxswitch.o arch/i386/sched/switch.o kernel/kernel.o kernel/kprintf.o kernel/debug.o kernel/mem/allocator.o kernel/mem/kmalloc.o kernel/utils/random.o kernel/tests/RandomTest.o kernel/tests/TestCenter.o -nostdlib -lk -lgcc arch/i386/crtend.o arch/i386/crtn.o
arch/i386/sched/ctxswitch.o:(.rodata._ZTIN9scheduler3PooE[typeinfo for scheduler::Poo]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
arch/i386/sched/ctxswitch.o:(.rodata._ZTIN9scheduler3FooE[typeinfo for scheduler::Foo]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
collect2: error: ld returned 1 exit status
Makefile:61: recipe for target 'bodos.kernel' failed

Does anyone know how to resolve this or I might be doing wrong?

Thanks a lot!

Greg


Top
 Profile  
 
 Post subject: Re: undefined reference to `vtable for __cxxabiv1::__class_t
PostPosted: Wed Apr 12, 2017 8:02 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
what this point is i writing is possibly totally bullshit. do not pay attention to it:

virtual functions are not real functions, they are function pointers, and they must be managed by the cpp runtime - maybe even relying on a memory manager - which you probably cant have by the system if you are making your own os.
oop on low level is not a good idea, its too ,,high''

you must disable all shared library, runtime library, etc and maybe the compiler will fallback to methonds capable to work ( --disable-shared , etc) or not

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: undefined reference to `vtable for __cxxabiv1::__class_t
PostPosted: Wed Apr 12, 2017 8:17 pm 
Offline

Joined: Wed Apr 12, 2017 7:32 pm
Posts: 3
As per http://wiki.osdev.org/C%2B%2B
"A lot of features C++ offers can be used on-the-fly; they require no additional support or code to use them properly (e.g. templates, classes, inheritance, virtual functions). There are however other parts of C++ that do require runtime support, which will be discussed in this article."

"RTTI is used for typeid and dynamic_cast. It requires runtime support as well. Disable it with -fno-rtti. A kernel has no access to run-time features, which are most likely operating system-dependent. Note that virtual functions work without RTTI."


Top
 Profile  
 
 Post subject: Re: undefined reference to `vtable for __cxxabiv1::__class_t
PostPosted: Wed Apr 12, 2017 9:00 pm 
Offline

Joined: Wed Apr 12, 2017 7:32 pm
Posts: 3
Sorry guys it was a mistake I made.
Long story short I was not really adding the -fno-exceptions -fno-rtti to the file I had to compile with virtual support.
I should have taken a closer look.
It works now.


Top
 Profile  
 
 Post subject: Re: undefined reference to `vtable for __cxxabiv1::__class_t
PostPosted: Thu Apr 13, 2017 1:28 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Geri wrote:
what this point is i writing is possibly totally bullshit. do not pay attention to it:

virtual functions are not real functions, they are function pointers, and they must be managed by the cpp runtime - maybe even relying on a memory manager - which you probably cant have by the system if you are making your own os.
oop on low level is not a good idea, its too ,,high''

you must disable all shared library, runtime library, etc and maybe the compiler will fallback to methonds capable to work ( --disable-shared , etc) or not


It IS bullshit, why did you write that?

_________________
Learn to read.


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

All times are UTC - 6 hours


Who is online

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