Cross Compiler

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

Cross Compiler

Post by gsingh2011 »

I've been using Cygwin GCC recently, and I'm getting some errors when I run my floppy.img file. People have been telling me to get a Cross Compiler but I don't really know what that is, how it differs from Cygwin GCC, and how to get one. Can anyone help? I'm running Windows XP right now.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: Cross Compiler

Post by Firestryke31 »

Basically, a cross compiler is a compiler that runs on one OS, but makes programs for another. So a Linux GCC that makes Windows EXEs is a cross compiler. Most of the time it's a Windows GCC making ELF files that's used in OS dev, because ELF is what GRUB understands and some argue it's a better format. Usually, you have to make it, but it's rather simple because you just have to type

Code: Select all

configure >options<
make
make install
or something similar. The biggest problem is knowing what options to put in, but you can find that in the wiki or on Google.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Cross Compiler

Post by Solar »

Every good solution is obvious once you've found it.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Cross Compiler

Post by gsingh2011 »

It took a while but I got GCC 4.3.3 built. The problem is when I execute the command:
gcc -o kernel.o -c kernel.c -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs

I get the error:
gcc: error trying to exec 'cc1': execvp: No such file or directory

What's wrong?

Edit: BTW, I didn't uninstall Cygwin GCC 4.3.2 or any other Cygwin GCC related program and I'm running the gcc command from the Cygwin bash shell. Don't tell me I have to uninstall the Cygwin GCC and then rebuild the one I just got... Building it took a while...
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: Cross Compiler

Post by xDDunce »

check that the binary outputof your new cross compiler is in you PATH variable. if not then you should add it (C:/example/gcc-build/bin) and then use i586-elf-gcc (if you followed the wiki tutorial) instead of gcc, so you use the right gcc.

hope this helps.

Cheers,
James.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Cross Compiler

Post by gsingh2011 »

Ok when I built it I used the commands:

export PREFIX=/usr/cross
export TARGET=i586-elf

cd /usr/src/build-gcc
export PATH=$PATH:$PREFIX/bin
../gcc-4.3.3/configure --target=$TARGET --prefix=$PREFIX --disable-nls \
--enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-mpfr=/usr/local
make all-gcc
make install-gcc

So is the command I need to add to the path variable

export PATH="/usr/cross/bin":$PATH
or
export PATH="/usr/src/build-gcc":$PATH

Edit: Neither of them work... Please help!
User avatar
JackScott
Member
Member
Posts: 1035
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Cross Compiler

Post by JackScott »

Try

Code: Select all

export PATH=$PATH:$PREFIX/bin
or

Code: Select all

export PATH=$PATH:/usr/cross/bin
Basically you just don't need the quotes ("") in there.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Cross Compiler

Post by gsingh2011 »

Ok I completely uninstalled everything and then reinstalled it. Now when I compile I get this message:

Code: Select all

/cygdrive/c/DOCUME~1/Gulshan/LOCALS~1/Temp/ccKTYMvb.s: Assembler messages:
/cygdrive/c/DOCUME~1/Gulshan/LOCALS~1/Temp/ccKTYMvb.s:4: Warning: .type pseudo-o
p used outside of .def/.endef ignored.
/cygdrive/c/DOCUME~1/Gulshan/LOCALS~1/Temp/ccKTYMvb.s:4: Error: junk at end of l
ine, first unrecognized character is `k'
/cygdrive/c/DOCUME~1/Gulshan/LOCALS~1/Temp/ccKTYMvb.s:17: Warning: .size pseudo-
op used outside of .def/.endef ignored.
/cygdrive/c/DOCUME~1/Gulshan/LOCALS~1/Temp/ccKTYMvb.s:17: Error: junk at end of
line, first unrecognized character is `k'
I'm getting really tired of these errors... Any one know what's wrong now?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Cross Compiler

Post by AJ »

Hi,

Do you have any other version of GCC installed (DJGPP or MinGW?). For some reason, you are attempting to access your system's "Local Settings\Temp" folder, which I wouldn't expect Cygwin to do (at least - I've never seen that before).

If you already have DJGPP or MinGW, uninstall them (or at least make sure that PATH doesn't point to them) to make sure that you are using Cygwin's version of GCC.

Another thing to point out is that Cygwin does not like spaces in paths, so if you are trying to access "/cygdrive/c/documents and settings/" the compile will generally fail. You need to do everything from a path within cygwin that does not use windows LFN paths with spaces in. You can get around this restriction by using "mount".

It looks like things are in a bit of a mess, really. If the points above do not apply, I would suggest deleting your cygwin tree (backing up any personal data!) and reinstalling from scratch with the exact settings and packages specified in the tutorial.

Cheers,
Adam
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Cross Compiler

Post by Love4Boobies »

This looks like a typical beginner problem. You installed MinGW and Cygwin with no GCC (if you used setup.exe, you didn't choose GCC from the development tools). I do however suggest that you build your cross-compiler using MinGW and MSYS as using the native Windows API will give faster binaries for your toolchain.

MSYS comes with a precompiled copy of GMP (that you'll have to download separately and extract to your MinGW directory). MPFR you'll have to build yourself (configure with "--prefix=c:\\mingw --disable-static --enable-shared" <-- replace with your MinGW installation directory using that format). You won't need to point to MPFR and GMP when configuring GCC.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Cross Compiler

Post by Solar »

...effectively giving the poor soul not one elaborate, field-tested tutorial to work with, but a tutorial assuming Cygwin and the recommendation to use a different path entirely, for so-claimed "faster toolchain"...

I wonder how many split-seconds one might save this way...
Every good solution is obvious once you've found it.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Cross Compiler

Post by Love4Boobies »

I didn't "assume" Cygwin, he mentioned using it. And it's a fact that Cygwin generates slower binaries since it uses a POSIX emulation layer (cygwin1.dll). It's common knowledge and they even mention it on their web site somewhere. And while it's probably not noticeable in small projects, as his operating system will grow it will certainly be important. And since it's not even one bit harder to build under MSYS instead then Cygwin, why on earth would you be against it?

Furthermore, I can't see any reason for writing a tuturial. Building is exactly the same since the same GNU tools are used, no matter the platform. The only thing that's worth mentioning is that you need to build MPFR as a DLL otherwise the build will fail under Windows (hence the "--disable-static --enable-shared").
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
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: Cross Compiler

Post by Combuster »

As solar said, difference is neglegible - running a full make under linux does not take a noticeable shorter amount of time as it does under windows.

And usually, you only update a few files. You spend a significant larger amount of time editing code than waiting for it to compile.
"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 ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Cross Compiler

Post by Solar »

Love4Boobies wrote:And since it's not even one bit harder to build under MSYS instead then Cygwin, why on earth would you be against it?
It's harder because the tutorial assumes Cygwin, and because Cygwin offers many tools that come in quite handy during further development.
Furthermore, I can't see any reason for writing a tuturial. Building is exactly the same since the same GNU tools are used, no matter the platform. The only thing that's worth mentioning is that you need to build MPFR as a DLL otherwise the build will fail under Windows (hence the "--disable-static --enable-shared").
About every other week, someone fails to build the cross-compiler with the tutorial...
Every good solution is obvious once you've found it.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Cross Compiler

Post by Love4Boobies »

Solar wrote:
Love4Boobies wrote:And since it's not even one bit harder to build under MSYS instead then Cygwin, why on earth would you be against it?
It's harder because the tutorial assumes Cygwin, and because Cygwin offers many tools that come in quite handy during further development.
As does MSYS.
Furthermore, I can't see any reason for writing a tuturial. Building is exactly the same since the same GNU tools are used, no matter the platform. The only thing that's worth mentioning is that you need to build MPFR as a DLL otherwise the build will fail under Windows (hence the "--disable-static --enable-shared").
About every other week, someone fails to build the cross-compiler with the tutorial...
Then they should do some more research prior to OSDev'ing. If you're not able to build a toolchain even when following a tutorial, you're not ready to develop an OS.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply