Kernel in C++, classes

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
znewsham
Posts: 9
Joined: Sat Sep 01, 2007 6:16 am

Kernel in C++, classes

Post by znewsham »

ok, i have a slight problem...well 2, the first, and probably the simpler is this, when i compile and link my kernel, i get these errors:
undefined reference to __alloca
undefined reference to ___main

even though i never call them, however if i change int main, to void main, i dont get these.

the second problem is i cant get my class CVideo to work, i have tested the functionallity of the method, outside a class, and it worked fine, but with it encapsulated, the OS, gets to the point where it should be called, and gets to the end (i set a screen char to show the end), but the actual method, does nothing...

i cant figure this out,

my ASM code is assembled using NASM
and my C++ code is compiled using whatever compiler comes with dev-cpp, using the LD linker

any help would be great
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Save yourself a lot of trouble... use a Cross-Compiler. 8)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

znewsham
Posts: 9
Joined: Sat Sep 01, 2007 6:16 am

Post by znewsham »

i am now utterly confused...does that mean that i have to make a compiler myself?

or can i just edit an existing one so that it does not give me the errors, also does that only relate to the first problem, or would that solve the issue with classes also, i have checked out the bonafide OS dev "doing a kernel in c++" tutorial, but i still cant make a class work
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

znewsham wrote:i am now utterly confused...does that mean that i have to make a compiler myself?

or can i just edit an existing one so that it does not give me the errors, also does that only relate to the first problem, or would that solve the issue with classes also, i have checked out the bonafide OS dev "doing a kernel in c++" tutorial, but i still cant make a class work
You tell your computer to make a compiler suited for your OS. That means, it doesn't pretend that you're using Windows and it stops inserting calls to __alloca etc.

For the second, it's probably a linking problem. I can't tell about the actual specific error since you don't provide enough information. What should the function do, what are you testing? Do you construct a proper object? Are you relying on a global object and are you calling the constructors in .ctors and .dtors?
znewsham
Posts: 9
Joined: Sat Sep 01, 2007 6:16 am

Post by znewsham »

when you say "you tell the compiler" does that mean that you use a command line option, or do i actually have to edit the code?

The object is a local object inside my main function

i don't do CVideo vid =new CVideo();
i simply do CVideo vid

it is not static

the method simply outputs text to the screen, and when i made it printf(), and put it in the same file with main(), it worked fine.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

znewsham wrote:when you say "you tell the compiler" does that mean that you use a command line option, or do i actually have to edit the code?
It means that you have to compile the source code of the compiler (with different configure flags). It does not imply changing the sourcecode. See the links to the wiki.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

znewsham wrote:when you say "you tell the compiler" does that mean that you use a command line option, or do i actually have to edit the code?

The object is a local object inside my main function

i don't do CVideo vid =new CVideo();
i simply do CVideo vid

it is not static

the method simply outputs text to the screen, and when i made it printf(), and put it in the same file with main(), it worked fine.
Is your stack large enough for the object, could you be overwriting system information or going outside of valid memory?
Post Reply