WinXP

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

WinXP

Post 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).
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:WinXP

Post 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.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Re:WinXP

Post by Kevin McGuire »

Yep. I use Microsoft Visual C++ to write mine. I like it, works nice with Windows.
DeathGauge

Re:WinXP

Post 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
Phugoid

Re:WinXP

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:WinXP

Post 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 ? :P
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:WinXP

Post 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 ;)
DeathGauge

Re:WinXP

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:WinXP

Post 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)
DeathGauge

Re:WinXP

Post 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
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:WinXP

Post 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.
Phugoid

Re:WinXP

Post 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.
DeathGauge

Re:WinXP

Post 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:).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:WinXP

Post 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.
DeathGauge

Re:WinXP

Post 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.
Post Reply