Page 1 of 1

OS Development using DJGPP and Bran's tutorial

Posted: Mon Mar 02, 2009 11:17 am
by dan144
Hi,
I'm trying to learn some kernel development but I'm having some troubles on the Bran's kernel development tutorial. I was able to get setup, compile and link the first assembly, and run it on virtual pc with a virtual floppy. I'm having some troubles now though, compiling the c code. I downloaded and installed the DJGPP from osdever.net's download section (with c++) and ran the installer. For some reason I get the following errors while trying to compiler:

----------Dan's Operating System----------
Welcome to the system compiler. This will take the system's source code and crea
te kernel.bin.
Press any key to continue . . .
In file included from <command line>:1:
c:/djgpp/lib/gcc-lib/djgpp/3.1/djgpp.ver:1:25: sys/version.h: No such file or di
rectory (ENOENT)
main.c:20: warning: return type of `main' is not `int'
c:/users/dan/desktop/operat~2/2009/source/tools/ld.exe: cannot open main.o: No s
uch file or directory (ENOENT)
Mission complete! kernel.bin is now in the \build folder.
Press any key to continue . . .


Here is my bat file:

Code: Select all

@ ECHO OFF
set DJGPP=C:\DJGPP\DJGPP.ENV
set PATH=C:\DJGPP\BIN;%PATH%
CLS
ECHO ----------Dan's Operating System----------
ECHO Welcome to the system compiler. This will take the system's source code and create kernel.bin.
PAUSE

rem compile the assembly code
tools\nasm -f aout -o start.o start.asm

rem gcc commands
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c

rem links files. remeber to add each *.o file to the end of this line
tools\ld -T link.ld -o build\kernel.bin start.o main.o
rem del *.o
ECHO Mission complete! kernel.bin is now in the \build folder.
PAUSE

I followed the tutorials perfectly and I have no idea why I'm getting these errors. Does anyone know what's being done wrong? Thank you guys for the help :)

Re: OS Development using DJGPP and Bran's tutorial

Posted: Mon Mar 02, 2009 3:21 pm
by Combuster
DJGPP is generally a bad idea, get cygwin and try again.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Mon Mar 02, 2009 8:09 pm
by quok
Combuster wrote:DJGPP is generally a bad idea, get cygwin and try again.
DJGPP is generally a bad idea. Get Cygwin, build a cross compiler, and try again.

There, fixed that for you. :-D

Re: OS Development using DJGPP and Bran's tutorial

Posted: Mon Mar 02, 2009 9:34 pm
by leledumbo
Just want to know, do we still need to build a cross compiler even if the kernel is in PE format?

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 12:27 am
by Solar
No, you don't. But why would you want to?

(Seriously. I don't flame PE format, but what was the design decision to go for PE format? "Because I don't have to build a cross-compiler then" doesn't cut it. ;) )

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 12:46 am
by leledumbo
No, you don't. But why would you want to?
I don't know either, in fact I use ELF (but it simply because not many tutorials use it, and GRUB can't load it directly). But someone else out there might want to have a Windows (or DOS) compatible binaries.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 2:59 am
by Solar
leledumbo wrote:But someone else out there might want to have a Windows (or DOS) compatible binaries.
What for?

The binary wouldn't run on Windows. Windows tools wouldn't be as readily available for self-hosted development (unless you're trying to be Windows compatible).

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 7:28 am
by leledumbo
What for?
I don't know, perhaps just to show that he can make something like Windows himself.
The binary wouldn't run on Windows
As you say, if that "someone else out there" wants to make a Windows compatible OS, surely the binary would run there too.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 7:37 am
by AndrewAPrice
leledumbo wrote:
What for?
I don't know, perhaps just to show that he can make something like Windows himself.
The binary wouldn't run on Windows
As you say, if that "someone else out there" wants to make a Windows compatible OS, surely the binary would run there too.
.... If you're OS isn't Windows compatible, then why would your binary run on a Windows-computable OS? Even if you use the PE executable format, it is merely a format for storing executable data inside of a file, it's the fact that you will be using your own system calls and library functions that will make your binaries not compatible with Windows.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Mar 03, 2009 9:04 am
by Combuster
MessiahAndrw wrote:a Windows-computable OS
Nice typo :D

Re: OS Development using DJGPP and Bran's tutorial

Posted: Wed Mar 04, 2009 6:02 am
by weezo
just go to the specified directory in error and remove the first line that #include system.h version

Re: OS Development using DJGPP and Bran's tutorial

Posted: Mon Dec 14, 2009 7:59 pm
by canmeng
I meet the same problem as dan144 and i don't know why.I follow what weezo has told me:the result is main.o can be created,but there are also many warnings.After that,I make use of another method:
1.I modify the "include <sytem.h>" into "include "system.h"",
2.take the system.h file out of the include directory.
3.when compiling the main.c into main.o,i used the following instruction:gcc -Wall -c -o main.o main.c

So,kernel.bin is also created,though there are also many warnings.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Dec 15, 2009 1:50 am
by qw
dan144 wrote:c:/djgpp/lib/gcc-lib/djgpp/3.1/djgpp.ver:1:25: sys/version.h: No such file or directory (ENOENT)
It seems that DJGPP is not properly set up. Check the DJGPP.ENV file and see if it contains somewhere on top:

Code: Select all

DJDIR=%:/>DJGPP%
and someweher below that, in a section named "cpp":

Code: Select all

CPLUS_INCLUDE_PATH=%/>;CPLUS_INCLUDE_PATH%%DJDIR%/lang/cxx;%DJDIR%/include
C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%%DJDIR%/include
"%DJDIR%/include" will expand to "C:/DJGPP/include" where "sys/version.h" should be found.
dan144 wrote:main.c:20: warning: return type of `main' is not `int'
You can safely ignore this. You may rename "main" to "kmain" or something similar, and adjust your "start.asm" accordingly. It's not required though.
dan144 wrote:c:/users/dan/desktop/operat~2/2009/source/tools/ld.exe: cannot open main.o: No such file or directory (ENOENT)
This is because "main.o" was never generated. You shouldn't use a batch file because it doesn't stop when an error occurs. Try MAKE instead.

By the way, why is LD in "c:/users/dan/desktop/operat~2/2009/source/tools" instead of "C:/DJGPP/bin"?

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Dec 15, 2009 2:27 am
by Solar
@ Hobbes:

dan144's post is over half a year old. 8)

@ canmeng:

Bran's tutorial suggests using DJGPP for Windows. Since we constantly, repeatedly get questions regarding problems with DJGPP, our answer was the GCC Cross-Compiler and Bare Bones tutorials.

Re: OS Development using DJGPP and Bran's tutorial

Posted: Tue Dec 15, 2009 3:33 am
by qw
Ah, didn't notice that.

Ah what the heck. I don't think necrophilia is a crime. On internet forums.