I need help with my c++ kernel..

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.
ineo

Re:I need help with my c++ kernel..

Post by ineo »

@Solar

In fact in the first post you read the following:
I am using Mandrake Linux 10, G++ compiler
So he is working under linux, its gcc produces ELF without any problem (and other format too). The problem may be different for people working under Winsux.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:I need help with my c++ kernel..

Post by Candy »

ineo wrote:
I am using Mandrake Linux 10, G++ compiler
So he is working under linux, its gcc produces ELF without any problem (and other format too). The problem may be different for people working under Winsux.
First of all, calling people names is not going to help build a good discussion is it? Call it Windows, even if you have to retype it 10 times to get it right.

Having a clean compiler also helps prevent including libraries that you shouldn't, using includes you shouldn't, bugs in the compiler version etc. There are a lot of advantages to having a separate compiler.

Also, if you succeed, you might be able to compile for a different machine :).
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:I need help with my c++ kernel..

Post by Solar »

ineo wrote: So he is working under linux, its gcc produces ELF without any problem (and other format too). The problem may be different for people working under Winsux.
Oh, there are many more issues than just ELF. He might want to support i386, while his compiler is set to target i686. He might accidentially include headers for libs that aren't there on his OS. He might want to use a later, or older compiler version. We might want to reproduce his errors on an identical setup without installing his flavor of Linux first.

Some day he might want to continue with the next step of setting up a cross-compilation C lib. And yet some time later, he might want to bootstrap a native compiler. Setting up a cross-compiler is a logical step you have to take sooner or later, and since it's fairly easy to do, why not do it right away and avoiding all those hassles above?

And I don't like the notion of a developer being inferor just because he's using Windows. Either Windows or Linux is little more to me than a platform for a mailer, a browser, an editor with decent GUI, and a bash shell. In an offline world, I would still prefer Windows over Linux any time, because the only thing it "winsux" at is privacy / security. But that's OT...
Every good solution is obvious once you've found it.
ineo

Re:I need help with my c++ kernel..

Post by ineo »

Sorry for the slang, I know its stupid, but as you said I never remember the spelling :p

I am not saying that it is better to work with a gcc "out of the box", but I say that saying to new OS devers to build a cross-compiler and so on to get started is a bit hard and not always necessary.
I've been doing OS development for several years without any special compiler since you may use switches that do most of the work (and linker scripts). That's even true with non opensource compiler.

Therefore I say someone may start using its gcc "out of the box" unless he needs some special features... He may enjoy working with his kernel quickly rather than spending time compiling gcc.

Sorry if you think I am flaming or trolling, I just thought it was the best advice to give to someone starting a c++ kernel: keep concentrated on the kernel as long as you don't need to go further with the compiling tools.
However you may have to look the ABI if you really want to do c++...

Good luck !

[attachment deleted by admin]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:I need help with my c++ kernel..

Post by Solar »

ineo wrote: I am not saying that it is better to work with a gcc "out of the box", but I say that saying to new OS devers to build a cross-compiler and so on to get started is a bit hard and not always necessary.
I've been doing OS development for several years without any special compiler since you may use switches that do most of the work (and linker scripts).
With the information given in the FAQ, it's as easy as compilation gets. Just copy, paste, execute...

Yes, you could instead figure out what kind of switches you'll need to set your toolchain to the intended target, to avoid including stuff you don't want etc., but that'll take about as much time. I have been able to answer "that problem will go away if you build a cross compiler as advertised in the FAQ" half a dozen times on this board already tells me enough to continue suggesting it.

And if the idea of building a cross-compiler following a clear-cut how-to scares you, you're probably in the wrong arena. ;-)
Sorry if you think I am flaming or trolling, I just thought it was the best advice to give to someone starting a c++ kernel: keep concentrated on the kernel as long as you don't need to go further with the compiling tools.
No offense taken, but he has problems with his setup... ;)
Every good solution is obvious once you've found it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:I need help with my c++ kernel..

Post by Solar »

All that being said, is there someone who *did* build a cross-compiler as advertised, and using NASM instead of GNU as? I'd like to add info on the correct NASM switches to the FAQ...
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:I need help with my c++ kernel..

Post by Candy »

Solar wrote: All that being said, is there someone who *did* build a cross-compiler as advertised, and using NASM instead of GNU as? I'd like to add info on the correct NASM switches to the FAQ...
using nasm for?
beyondsociety

Re:I need help with my c++ kernel..

Post by beyondsociety »

Solar wrote: All that being said, is there someone who *did* build a cross-compiler as advertised, and using NASM instead of GNU as? I'd like to add info on the correct NASM switches to the FAQ...
At the moment I just compile my assembly files seperate with nasm, then compile the C code and link.

I would be intrested in this if you do in fact find a way to do it. Also on the tutorial on cross-compiling: how would I set the target for supporting all formats?. In the example you have it as: export TARGET=i586-elf.
EclipseOS

Re:I need help with my c++ kernel..

Post by EclipseOS »

Well I can get it to boot through GRUB, but the bootloader that Neo gave me doesn't work. I've tried other boot sectors but they still won' boot my flat binary file. Is it my file or could it be the boot loaders that I am using?
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:I need help with my c++ kernel..

Post by Neo »

where does the error occur? what happens? can you give post the binary file of your kernel. is the binary actually linked to start from the (well...) start of your code? (which is loaded to the 1MB mark by the bootloader)
Only Human
EclipseOS

Re:I need help with my c++ kernel..

Post by EclipseOS »

Here's the error from boot1.asm.

C:\WINDOWS\Desktop>nasm boot1.asm -f bin -o boot.bin

boot1.asm:1: error: parser: instruction expected
boot1.asm:295: error: symbol `undefined' redefined
boot1.asm:299: error: symbol `undefined' redefined
boot1.asm:300: error: unrecognised directive [Close]
boot1.asm:303: error: symbol `undefined' redefined
boot1.asm:304: error: unrecognised directive [Close]
boot1.asm:307: error: symbol `undefined' redefined

and here's number 2:

C:\WINDOWS\Desktop>nasm boot2.asm -f bin -o boot2.bin
boot2.asm:458: error: symbol `GDT_BASE' undefined
boot2.asm:459: error: symbol `gdt' undefined
boot2.asm:460: error: symbol `GDT_SIZE' undefined
boot2.asm:467: error: symbol `gdt_descriptor' undefined
boot2.asm:471: error: symbol `CODE_SEL' undefined
boot2.asm:483: error: symbol `DATA_SEL' undefined
boot2.asm:488: error: symbol `STACK_SEL' undefined
boot2.asm:493: error: symbol `CODE_SEL' undefined
boot2.asm:526: warning: uninitialised space declared in .data section: zeroing
boot2.asm:527: warning: uninitialised space declared in .data section: zeroing
boot2.asm:528: warning: uninitialised space declared in .data section: zeroing
boot2.asm:537: error: phase error detected at end of assembly.


My files are attatched to this message.
Thanx


[attachment deleted by admin]
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:I need help with my c++ kernel..

Post by Neo »

crumbs i forgot the gdt.inc file. here it is along with all the other files
<edit>
what are all those .o files doing i just wanted the plain binary which should be one single file as your kernel? (read monlithic)
</edit>
<edit>
hmmm fast solns are not good. must do that properly later
</edit>


[attachment deleted by admin]
Only Human
EclipseOS

Re:I need help with my c++ kernel..

Post by EclipseOS »

Thanx I'll try that.
EclipseOS

Re:I need help with my c++ kernel..

Post by EclipseOS »

boot.asm compiled fine.
But there is another error in boot2.asm:

C:\WINDOWS\Desktop>nasm boot2.asm -f bin -o boot2.bin
boot2.asm:526: warning: uninitialised space declared in .data section: zeroing
boot2.asm:527: warning: uninitialised space declared in .data section: zeroing
boot2.asm:528: warning: uninitialised space declared in .data section: zeroing
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:I need help with my c++ kernel..

Post by Neo »

thats ok they're only warnings.(i will correct them later).
<edit>
they're corrected now. re-download from above.
</edit>
Only Human
Post Reply