Page 1 of 1

C++ instead o C

Posted: Sat Aug 07, 2004 6:41 am
by n00
I?d like to re-write a kernel in C++ instead of C. I read that you have to do something special to be able to use global/static objects?

I tried to do it like this article:
http://www.invalidsoftware.net/os/?the_id=11

BUT when Im linking, I get the errormessage:
Loader.o(.text+0x1):Loader.o: undefined reference to `__main'
Loader.o(.text+0xb):Loader.o: undefined reference to `__atexit'

and I have no idea why. They are stored in a file called support.cpp, which I compile and link. I use DJGPP and nasm.

Re:C++ instead o C

Posted: Sat Aug 07, 2004 10:56 am
by n00
and it?s weird because the file Loader.asm do finds the regular main function, but not the _main and _atexit.

Re:C++ instead o C

Posted: Sun Aug 08, 2004 10:18 am
by Solar
_atexit points to using the wrong compiler options. _atexit is a function usually supplied by the C/C++ runtime environment - which you do not have at your disposal when compiling your kernel.

You are probably using -ffreestanding; this option is not supported by G++. You might want to check out the FAQ on BareBonesC++.