Problem linking(ld) c++ files

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
Phinos
Posts: 2
Joined: Sun Jun 01, 2008 4:13 am

Problem linking(ld) c++ files

Post 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.
grover
Posts: 17
Joined: Wed Apr 30, 2008 7:20 am

Re: Problem linking(ld) c++ files

Post 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.
Phinos
Posts: 2
Joined: Sun Jun 01, 2008 4:13 am

Post by Phinos »

Thanks a lot =D, it worked. I still have a lot of thinks to learn hehehe =P
Post Reply