GCC Cross compiler in Ubuntu 12.04

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
snasim2002
Member
Member
Posts: 37
Joined: Sat Apr 11, 2015 9:37 am

GCC Cross compiler in Ubuntu 12.04

Post 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.
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: GCC Cross compiler in Ubuntu 12.04

Post 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.
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: GCC Cross compiler in Ubuntu 12.04

Post 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.
snasim2002
Member
Member
Posts: 37
Joined: Sat Apr 11, 2015 9:37 am

Re: GCC Cross compiler in Ubuntu 12.04

Post 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 ??
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: GCC Cross compiler in Ubuntu 12.04

Post 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?
snasim2002
Member
Member
Posts: 37
Joined: Sat Apr 11, 2015 9:37 am

Re: GCC Cross compiler in Ubuntu 12.04

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

Re: GCC Cross compiler in Ubuntu 12.04

Post by Candy »

Double-check what you're building - the wiki says not to build libiberty, but instead to build all-gcc and target-libgcc.
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: GCC Cross compiler in Ubuntu 12.04

Post 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.
snasim2002
Member
Member
Posts: 37
Joined: Sat Apr 11, 2015 9:37 am

Re: GCC Cross compiler in Ubuntu 12.04

Post 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
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: GCC Cross compiler in Ubuntu 12.04

Post 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.
snasim2002
Member
Member
Posts: 37
Joined: Sat Apr 11, 2015 9:37 am

Re: GCC Cross compiler in Ubuntu 12.04

Post 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.
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: GCC Cross compiler in Ubuntu 12.04

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