Grub Error 13 on Cygwin but not Linux

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
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Grub Error 13 on Cygwin but not Linux

Post by gsingh2011 »

I followed the Bare Bones tutorial a year or two ago on Ubuntu and got it working. Now I transferred it over to Cygwin on windows and it compiles and links fine but when I try to run it in qemu for windows and I get Error 13: Invalid or unsupported executable format. I followed this guide too: http://wiki.osdev.org/Grub_Error_13 and it didn't work.

So why is cygwin causing a problem?
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: Grub Error 13 on Cygwin but not Linux

Post by Rudster816 »

You need to setup a cross compiler. http://wiki.osdev.org/GCC_Cross-Compiler

If your using the default Cygwin tools, then it is outputting a PE file, which GRUB does not support without the a.out kludge.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Grub Error 13 on Cygwin but not Linux

Post by gsingh2011 »

Thanks, but I'm running into an error. I followed all the directions in the wiki and ran the following commands without any error.

Code: Select all

export PREFIX=/usr/local/cross
export TARGET=i586-elf
cd /usr/src
mkdir build-binutils build-gcc

cd /usr/src/build-binutils
../binutils-x.xx/configure --target=$TARGET --prefix=$PREFIX --disable-nls
make all
make install

cd /usr/src/build-gcc
export PATH=$PATH:$PREFIX/bin
../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls \
    --enable-languages=c,c++ --without-headers
The problem is when I type the next command, make all-gcc, I get the following error:
make: *** No rule to make target `all-gcc'. Stop.

I followed all of the instructions, so why am I getting this error?

I attached config.log, a file produced in build-gcc.
Attachments
config.txt
(20.67 KiB) Downloaded 69 times
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Grub Error 13 on Cygwin but not Linux

Post by Owen »

Sorry, but quite blatantly GCC's configure did not complete successfully:
config.log wrote: The following requested languages could not be built: c++
Supported languages are: c,lto
You downloaded the gcc-base rather than gcc tarball. If you didn't want a C++ compiler, this is fine; but the base tarball doesn't contain g++, so you can't pass c++ to --enable-languages.

Note to self: Update the cross compiler wiki article to do a single tree build of Binutils, GCC, MPFR & co. It's less error prone and faster...
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Grub Error 13 on Cygwin but not Linux

Post by gsingh2011 »

Yea, I didn't really need C++ but I decided to follow the wiki word for word so that if I ran into an error here I could say that I followed it word for word. I thought it would ignore that and go proceed with configuring it for C. So I changed that line to only support C and so now I have the cross compiler running. I had to make some changes to my compile script like adding -Wno-pointer-to-int-cast and -fno-builtin because I got a lot of warnings I didn't get before but no errors from the compiler. The problem is I'm getting this error from the linker now: Object Files/kernel.o: file not recognized: File format not recognized

Did I build the compiler wrong? I'll repeat the steps while I'm waiting for a reply but hopefully there's an easy fix.

EDIT: I built gcc again and I'm still getting the same error.

EDIT2:I looked through config.log and I found something I didn't see before:
conftest.c: In function `main':
conftest.c:16: error: `choke' undeclared (first use in this function)
conftest.c:16: error: (Each undeclared identifier is reported only once
conftest.c:16: error: for each function it appears in.)
conftest.c:16: error: parse error before "me"

The config.log is attached.

EDIT3:Ok, I was stupid and it was all just a typing mistake :/

I'm working on getting rid of the new error error: instruction not supported in 64-bit mode. But I'm going to try to figure it out. If I don't have any luck I'll post back here in a few days.
Attachments
config (2).txt
(30.01 KiB) Downloaded 64 times
Post Reply