Page 1 of 1
Using GCC (DJGPP) Under Windows
Posted: Thu Apr 08, 2004 7:37 am
by XStream
Hi Guys,
I was wondering if anyone here who is developing their OS on windows could give me a guideline on how to use DJGPP to compile some sample source code I got. Just basically how to compile to a flat binary.
So if anyone has a spare minute, please let me know.
Thanks.
Re:Using GCC (DJGPP) Under Windows
Posted: Thu Apr 08, 2004 9:34 am
by ich_will
If you have installed all correct you can simple type in the console:
gcc filename.c
or to compile and link all files of an directory:
gcc *.c
this will create lots of *.o files and one a.out and one a.exe (you can give it a better name with gcc *.c -o name.exe)
if you want to compile a kernel which will be load to 0x100000
you can use this linker skript:
/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
__DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
than type if all your files in one directory:
gcc -c *.c ; -c says that gcc only compiles the files
ld -T link.ld *.o -o kernel.bin
you can get more help if you type:
"gcc --help" or "ld --help"
Re:Using GCC (DJGPP) Under Windows
Posted: Thu Apr 08, 2004 9:55 am
by ich_will
if forgotten:
if you haven't installed DJGPP yet, my install (
www.klafft.de.vu/install.exe) programm:
copy all files you've downloaded for DJGPP in one direcory (all *.zip files and the unzip32.exe), than my install.exe. Start it and enter a directory (f.e. c:\DJGPP), press j and hope, maybe you will be asked a few times if you will replace some files, enter A for all.
you have to add ...\bin to the system path variable, where ... is your install path:
f.e. if you install it to c:\DJGPP:
under Win9x add this line to your autoexec.bat:
set PATH=%PATH%;c:\DJGPP\bin
under WinXP (and i think under 2000/NT too??):
copy by the DJGPP zip file picker:
Right-click My Computer, select Properties. Select the Advanced tab, then the Environment Variables button. Edit the Path (or PATH, whichever exists) system variable to include C:\DJGPP\BIN at the front. (If you are not an administrator, add it to the PATH variable in the User Variables section, or add a new PATH user environment variable which contains only C:\DJGPP\BIN) Add a new variable DJGPP set to C:\DJGPP\DJGPP.ENV (system variable if possible, user variable if not an administrator) .
You'll need to close and reopen your MS-DOS windows for these changes to take effect
now I think I have to work. If you want the source of my programm mail me:
[email protected]
(its really nothing special).
Re:Using GCC (DJGPP) Under Windows
Posted: Thu Apr 08, 2004 12:35 pm
by Neo
Alternatively you could download the from osdever.net
here
it is a self extracting file with instructions to install. Read and install.
Re:Using GCC (DJGPP) Under Windows
Posted: Thu Apr 08, 2004 6:07 pm
by XStream
Thanks for the help guys.
Ok, no idea about linker scripts, where can I get docs about what they mean and how to use them. I would search google but I think that someone here will be able to give me some more quality info that what I can find myself searching. I may as well harness the knowledge that guys already have.
Re:Using GCC (DJGPP) Under Windows
Posted: Fri Apr 09, 2004 3:48 am
by Pype.Clicker
and if you still haven't noticed it on the
WikiFAQ, it's generally a poor idea to use DjGpp under windows XP. Cygwin gives better results for technical reasons i will not re-explain a Nth time here.
If you're starting a new project rather than trying to compile something that already exists and use WinXP (or another WinNT), consider installing cygwin instead
Re:Using GCC (DJGPP) Under Windows
Posted: Fri Apr 09, 2004 7:08 am
by XStream
What about Win2k?
I will be compiling other projects to see how they run etc... But my own project will be started from scratch.
Thanks.
Re:Using GCC (DJGPP) Under Windows
Posted: Fri Apr 09, 2004 7:55 am
by beyondsociety
I have in the past used DJGPP on windows 2000 and it worked alright. But since I wanted more of a linux development on my windows 2000 computer, I choose cygwin. Its pretty easy and striaght forward to setup.
The only problem Ive had was: cygwin ld linker outputs only PE files. So if you want to use elf, coff, or bin, then you first have to compile source to pe (.exe) and then convert it to what format you want. Also you will need to get familar with makefiles. With djgpp its much easier: you can use .batch file for compiling.
It wasnt too much of a pain, but now I dont have that problem because I have just build a cross-compiler. I suggest you create one, if you decide to use cygwin as it will make it alot easier for you. You can find out how on the wikiFAQ for mega-tokyo.
Hope this helps.
Re:Using GCC (DJGPP) Under Windows
Posted: Fri Apr 09, 2004 9:09 am
by Pype.Clicker
Win2K is a WinNT and thus better likes cygwin, WinME is Win9x and thus should behave decently with DJGPP -- hum, except i never succeeded in making WinME behave decently with anything at all and reinstalled Win98 after a few weeks ;D
Re:Using GCC (DJGPP) Under Windows
Posted: Fri Apr 09, 2004 8:00 pm
by XStream
This sounds good. I will check out creating a cross-compiler. I don't know how I'll go, but I'll give it a try.
Thanks for the help.