Page 1 of 1

GCC Cross compiler in Ubuntu 12.04

Posted: Tue Apr 28, 2015 12:42 am
by snasim2002
Hi,
I'm using ubuntu 12.04, and i am a newbie to os devolopment. I have successfully built cross binutils, but i am stuck at making a gcc cross compiler. It will really hhelp me if someone gives a link to a working copy of a gcc cross compiler.
Thanks in advance.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Tue Apr 28, 2015 12:57 am
by iansjack
No, I don't think so. (And how can anyone give you a cross compiler when they don't know which processor you are targetting.)

You'll come up against a number of problems during your adventures in OS development. If you are going to give up at the first hurdle and ask others to do the work for you I think your voyage will be a short and boring one. Buckle down and solve your problem with creating a cross compiler. For starters you may want to tell us exactly what commands you typed in and what results you got. Theen it might be possible to make sensible suggestions.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Tue Apr 28, 2015 8:02 am
by ExeTwezz
Hello and welcome to forums *blah-blah-blah*,

Is the problem that making the GCC throws an error and compilation terminates? If so, I guess that this may be caused by incompatible versions of binutils and GCC, and I would like to present you these two good articles (however, seems like that you're familiar with the former one):
The latter one contains a great table for newbies like you and not only, see it.

Also, some errors may be solved by Googling, as some links may point to mailing lists/forums that finally link to a patch.

Edit: Also, be sure that your compiler (usual `gcc' command) can build the GCC version of your choice. I've never faced with a problem that host GCC can't build the target binutils or GCC, so I can't help you in this case.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Wed Apr 29, 2015 4:46 am
by snasim2002
I am targeting the i686-elf target, because i have to do so. (It is mentioned in the cross compiler tutorial that grub can boot only elf kernels.)
I guess i can use some bootloader other than grub ?? would that solve my problem ??

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Wed Apr 29, 2015 5:24 am
by ExeTwezz
snasim2002 wrote:I am targeting the i686-elf target, because i have to do so. (It is mentioned in the cross compiler tutorial that grub can boot only elf kernels.)
I guess i can use some bootloader other than grub ?? would that solve my problem ??
Of course, you can. But it won't solve your problem because GCC and bootloaders are not even related to each other (except that a bootloader might require GCC as a compiler).

What error do you get?

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Wed Apr 29, 2015 5:35 am
by snasim2002
Every thing worked fine for me in the gcc cross compiler installation, but at the end i got:
make[1]: *** No rule to make target `../include/ansidecl.h', needed by `regex.o'. Stop.
make[1]: Leaving directory `/home/os/cross/src/gcc/build-i686-pc-linux-gnu/libiberty'
make: *** [all-build-libiberty] Error 2
make: *** No rule to make target `all-target-libgcc'. Stop.
/bin/sh ./mkinstalldirs /home/os/cross/cross /home/os/cross/cross
make[1]: Entering directory `/home/os/cross/src/gcc/fixincludes'
make[1]: *** No rule to make target `install'. Stop.
make[1]: Leaving directory `/home/os/cross/src/gcc/fixincludes'
make: *** [install-fixincludes] Error 2
make: *** No rule to make target `install-target-libgcc'. Stop.

Note that i'm trying to install binutils and gcc at the same directory.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Wed Apr 29, 2015 6:09 am
by Candy
Double-check what you're building - the wiki says not to build libiberty, but instead to build all-gcc and target-libgcc.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Wed Apr 29, 2015 7:09 am
by ExeTwezz
snasim2002 wrote:Note that i'm trying to install binutils and gcc at the same directory.
snasim2002 wrote:I have successfully built cross binutils, but i am stuck at making a gcc cross compiler.
Seems like you've incorrectly built the binutils (as you want to build the binutils and GCC in the same directory). This might help you: http://stackoverflow.com/a/6228588. Follow the instructions in that answer (except configure and make, see below), but don't forget to
  • change the version numbers of binutils and GCC;
  • if you've installed the dependencies (such as mpfr or mpc) using apt-get, you don't need to do any instructions related to them.
However, you will need to use the configure instruction (and only) and the make instructions from the GCC Cross-Compiler article in order to build a cross-compiler:

Code: Select all

$ ../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
---
$ make all-gcc
$ make all-target-libgcc
$ make install-gcc
$ make install-target-libgcc
---
# If the binutils were not installed, run
$ make install    # - this will fail. However, binutils will be installed into $PREFIX.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Sun May 03, 2015 12:21 am
by snasim2002
Please tell me what you have done for building a gcc cross compiler in ubuntu 12.04 from starting;
including versions of mpc, mpfr, gmp, etc

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Sun May 03, 2015 1:03 am
by ExeTwezz
snasim2002 wrote:Please tell me what you have done for building a gcc cross compiler in ubuntu 12.04 from starting;
including versions of mpc, mpfr, gmp, etc
So, the instructions in my previous post are a bit hacky (regarding installing binutils) and I personally prefer building and installing GCC and Binutils separately, as it's more convenient. Yesterday, I've successfully built GCC 5.1.0 and Binutils 2.25 (before that, I was using GCC 4.9.2 and the same version of Binutils, 2.25). The Linux distribution I'm using provides all the dependencies that GCC and Binutils need (GMP, MPFR, MPC, and texinfo; though there are more), so I've installed them using the package manager.

If you want versions, then:
  • GMP 5.1.3-r1
  • MPFR 3.1.2-r1
  • MPC 1.0.1
  • texinfo 4.13-r2
I'm not sure why you're asking about versions, as Ubuntu provides these packages for you, and they're already suitable for building a cross-compiler.

For instructions, see GCC Cross-Compiler.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Fri May 08, 2015 12:49 am
by snasim2002
I have suceessfully compiled my os (without a cross toolchain), it has "print_screen" and "clear_sreen" support. I just modified my linker script a bit.
It ran correctly by GRUB.

Re: GCC Cross compiler in Ubuntu 12.04

Posted: Fri May 08, 2015 8:24 am
by Combuster
snasim2002 wrote:I have suceessfully compiled my os (without a cross toolchain), it has "print_screen" and "clear_sreen" support. I just modified my linker script a bit.
It ran correctly by GRUB.
I guess I should consider you lucky. Ubuntu's own version is heavily patched with OSdev-unfriendly items and doesn't work for most people.