OS Development using DJGPP and Bran's tutorial

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
dan144
Posts: 1
Joined: Mon Mar 02, 2009 11:12 am

OS Development using DJGPP and Bran's tutorial

Post 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 :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: OS Development using DJGPP and Bran's tutorial

Post by Combuster »

DJGPP is generally a bad idea, get cygwin and try again.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: OS Development using DJGPP and Bran's tutorial

Post 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
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Re: OS Development using DJGPP and Bran's tutorial

Post by leledumbo »

Just want to know, do we still need to build a cross compiler even if the kernel is in PE format?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OS Development using DJGPP and Bran's tutorial

Post 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. ;) )
Every good solution is obvious once you've found it.
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Re: OS Development using DJGPP and Bran's tutorial

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OS Development using DJGPP and Bran's tutorial

Post 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).
Every good solution is obvious once you've found it.
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Re: OS Development using DJGPP and Bran's tutorial

Post 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.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS Development using DJGPP and Bran's tutorial

Post 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.
My OS is Perception.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: OS Development using DJGPP and Bran's tutorial

Post by Combuster »

MessiahAndrw wrote:a Windows-computable OS
Nice typo :D
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
weezo
Posts: 9
Joined: Wed Jul 23, 2008 4:33 am
Location: Egypt

Re: OS Development using DJGPP and Bran's tutorial

Post by weezo »

just go to the specified directory in error and remove the first line that #include system.h version
canmeng
Posts: 1
Joined: Mon Dec 14, 2009 7:06 am

Re: OS Development using DJGPP and Bran's tutorial

Post 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.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: OS Development using DJGPP and Bran's tutorial

Post 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"?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OS Development using DJGPP and Bran's tutorial

Post 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.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: OS Development using DJGPP and Bran's tutorial

Post by qw »

Ah, didn't notice that.

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