C++ instead o C

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
n00

C++ instead o C

Post 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.
n00

Re:C++ instead o C

Post by n00 »

and it?s weird because the file Loader.asm do finds the regular main function, but not the _main and _atexit.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:C++ instead o C

Post 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++.
Every good solution is obvious once you've found it.
Post Reply