Page 1 of 1

Problem linking(ld) c++ files

Posted: Sun Jun 01, 2008 4:31 am
by Phinos
Hello everybody, i'm new to OS development and I was reading some of the wiki tutorials and I managed to build a simple kernel in C, but I'm more used to OOP, so I want to build it in C++. But I got a problem when linking 2 object files compiled with g++, I'm doing like this:

ld -T linker.ld -o kernel.bin entry.o main.o system.o

entry.o is an object file compiled by nasm, main.o and system.o are object files compiled by g++. ld returns me this message: main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
If I just link main.o and entry.o it links perfectly, I have no idea of what's happening.

Re: Problem linking(ld) c++ files

Posted: Sun Jun 01, 2008 4:51 am
by grover
Simple solution: You seem to either use exceptions or have not turned off exception handling in your g++ settings.
Phinos wrote:main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
.eh_frame is an exception handling frame generated by the compiler. It uses some compiler intrinsic, which is probably located in another library you need to link with.

I'd turn off rtti and exceptions for a kernel though, so just add -fno-rtti and -fno-exceptions to your build settings for c++ files.

Posted: Sun Jun 01, 2008 6:12 am
by Phinos
Thanks a lot =D, it worked. I still have a lot of thinks to learn hehehe =P