Page 1 of 1
Kernel in C++, classes
Posted: Sat Sep 01, 2007 6:42 am
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
Posted: Sat Sep 01, 2007 7:39 am
by Brynet-Inc
Save yourself a lot of trouble... use a
Cross-Compiler.
Posted: Sat Sep 01, 2007 7:41 am
by bluecode
Posted: Sat Sep 01, 2007 8:01 am
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
Posted: Sat Sep 01, 2007 8:14 am
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?
Posted: Sat Sep 01, 2007 8:17 am
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.
Posted: Sat Sep 01, 2007 1:21 pm
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.
Posted: Sun Sep 02, 2007 4:35 am
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?