Cross Compiler
-
- Member
- Posts: 83
- Joined: Tue Feb 03, 2009 11:37 am
Cross Compiler
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.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Cross Compiler
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
or something similar. The biggest problem is knowing what options to put in, but you can find that in the wiki or on Google.
Code: Select all
configure >options<
make
make install
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?
-
- Member
- Posts: 83
- Joined: Tue Feb 03, 2009 11:37 am
Re: Cross Compiler
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...
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...
Re: Cross Compiler
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.
hope this helps.
Cheers,
James.
-
- Member
- Posts: 83
- Joined: Tue Feb 03, 2009 11:37 am
Re: Cross Compiler
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!
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!
- JackScott
- 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
Try
or
Basically you just don't need the quotes ("") in there.
Code: Select all
export PATH=$PATH:$PREFIX/bin
Code: Select all
export PATH=$PATH:/usr/cross/bin
-
- Member
- Posts: 83
- Joined: Tue Feb 03, 2009 11:37 am
Re: Cross Compiler
Ok I completely uninstalled everything and then reinstalled it. Now when I compile I get this message:
I'm getting really tired of these errors... Any one know what's wrong now?
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'
Re: Cross Compiler
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
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
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Cross Compiler
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.
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 ]
[ Project UDI ]
Re: Cross Compiler
...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...
I wonder how many split-seconds one might save this way...
Every good solution is obvious once you've found it.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Cross Compiler
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").
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 ]
[ Project UDI ]
- Combuster
- 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
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.
And usually, you only update a few files. You spend a significant larger amount of time editing code than waiting for it to compile.
Re: Cross Compiler
It's harder because the tutorial assumes Cygwin, and because Cygwin offers many tools that come in quite handy during further development.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?
About every other week, someone fails to build the cross-compiler with the tutorial...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").
Every good solution is obvious once you've found it.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Cross Compiler
As does MSYS.Solar wrote:It's harder because the tutorial assumes Cygwin, and because Cygwin offers many tools that come in quite handy during further development.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?
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.About every other week, someone fails to build the cross-compiler with the tutorial...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 ]
[ Project UDI ]