Page 1 of 2
WinXP
Posted: Tue Jan 10, 2006 4:42 pm
by DeathGauge
This has probably been done to death, but is it possible to do OS development under Windows XP? I've tried numerous times and get the surprise of being able to assemble the object file but upon linking I get errors of it not being able to use the object file. Something about unrecognized format. On my PC I have Windows XP with MinGW (GCC) and I use NASM and Bochs for my x86 emulator. I followed numerous tuts and got the same odd error concerning the object file. Any help would be greatly appreciated. I will post the example I have tested to get the error when I get home later (at college courses right now before class).
Re:WinXP
Posted: Tue Jan 10, 2006 5:18 pm
by kataklinger
If you tell us more about errors you are getting, maybe we could help you. And what options do you use to compile source and to link object files?
I'm using Windows XP for development and it is a good platform for system development like Linux. I use Microsoft (this one is free), Intel C/C++ compilers and NASM without problems. And I'm not very familiar with MinGW/DJGPP/Cygwin/GCC.
Re:WinXP
Posted: Tue Jan 10, 2006 7:33 pm
by Kevin McGuire
Yep. I use Microsoft Visual C++ to write mine. I like it, works nice with Windows.
Re:WinXP
Posted: Tue Jan 10, 2006 9:13 pm
by DeathGauge
I get tutorials and follow them to a 'T' and do like so:
nasm -f aout -o start.o start.asm
ld -T link.ld -o kernel.bin start.o
The error it gives is thus:
ld: start.o: file not recognized: File format not recognized
Re:WinXP
Posted: Tue Jan 10, 2006 10:23 pm
by Phugoid
Which target does your version of ld support? (ld --help)
Which target are you asking it to link for in the linker script? (binary?)
You may find the last few posts in this thread useful:
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=8790
Re:WinXP
Posted: Wed Jan 11, 2006 3:36 am
by Pype.Clicker
Phugoid wrote:
Which target does your version of ld support? (ld --help)
More specifically, you should check your linker supports "aout" or compile the 'nasm' file to something else (presumably coff)
look out for output like
Code: Select all
ld: supported targets: elf32-i386 a.out-i386-linux efi-app-ia32 elf32-little elf32-big elf64-x86-64 elf64-little elf64-big srec symbolsrec tekhex binary ihex trad-core
ld: supported emulations: elf_i386 i386linux elf_x86_64
You basically have the following options on MsWindows:
*
use cygwin as it is provided, and adapt your tools/build system to work with COFF standards (e.g. -fno-leading-underscore, AOUT kludge for GRUB, etc.)
*
create a cross-compiler out of cygwin, for instance, that will exactly suit your needs.
*
use microsoft tools, with some customization to make them produce useful bits.
Note that each path has its drawbacks and that you'll need to check the tutorials you follow are compatible with your working environment, or adapt (either the tutorial or the environment) to make them match.
Yep. I use Microsoft Visual C++ to write mine. I like it, works nice with Windows.
lol ;D it'd be pretty pathetic otherwise, no ?

Re:WinXP
Posted: Wed Jan 11, 2006 4:04 am
by kataklinger
@DeathGauge:
If you only use NASM, it can produce binary format without linking.
[tt]nasmw -o kernel.bin start.asm[/tt]
@Pype:
;D
He probbably tought that it works nice for OS development under Windows

Re:WinXP
Posted: Wed Jan 11, 2006 6:57 am
by DeathGauge
Yeah I'm linking binary in my script. And the output form ld -help is as follows:
Code: Select all
ld: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec s
ymbolsrec tekhex binary ihex
ld: supported emulations: i386pe
Re:WinXP
Posted: Wed Jan 11, 2006 7:54 am
by Pype.Clicker
if that's the case, "nasm -f elf ..." should do the trick when you'll have several files to link together (since elf32-i386 is supported)
Re:WinXP
Posted: Wed Jan 11, 2006 8:39 am
by DeathGauge
I'm going to try something different. The linker seems to be the problem and the djgpp ld supports a lot more of that stuff. When I do as you said I get a new message.
nasm -f elf -o start.o start.asm
ld -T link.ld -o kernel.bin start.o
ld: PE operations on non PE file
Re:WinXP
Posted: Wed Jan 11, 2006 9:02 am
by Candy
DeathGauge wrote:
I'm going to try something different. The linker seems to be the problem and the djgpp ld supports a lot more of that stuff. When I do as you said I get a new message.
nasm -f elf -o start.o start.asm
ld -T link.ld -o kernel.bin start.o
ld: PE operations on non PE file
DJGPP doesn't support ELF. Try some other output format for nasm, say, PE.
Might I hint at a cross-compiler, as described in the OS FAQ? You can reach it by clicking on the "MEGA-TOKYO.COM" banner at the top.
Re:WinXP
Posted: Wed Jan 11, 2006 10:17 am
by Phugoid
Pype: the linker script may also need to be changed to target ELF. I assume it currently has OUTPUT_FORMAT("binary") near the top.
Re:WinXP
Posted: Wed Jan 11, 2006 10:22 am
by DeathGauge
I found the problem. MinGW's implements GCC differently than DJGPP. DJGPP works perfectly for OS development though. So I copied DJGPP's ld linker and renamed it to djld. So when I do this:
nasm -f aout -o start.o start.asm
djld -T link.ld -o kernel.bin start.o
It compiles perfectly:).
Re:WinXP
Posted: Wed Jan 11, 2006 10:54 am
by Pype.Clicker
i cannot promise it will change your life, but you could want to use cygwin instead of mingw/djgpp: they're in many ways too much targetted at DOS/windows apps respectively to be convenient for OSDev.
Re:WinXP
Posted: Wed Jan 11, 2006 9:04 pm
by DeathGauge
I have cygwin but it only shows what is on my PC now. How do I make it so that it doesn't use MinGW or DJGPP? I downloaded what I thought was the proper packages but it is just reading my windows .bat files for path info.