OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 4:55 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: GCC Cross compiler in Ubuntu 12.04
PostPosted: Tue Apr 28, 2015 12:42 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Tue Apr 28, 2015 12:57 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Tue Apr 28, 2015 8:02 am 
Offline
Member
Member

Joined: Sun Sep 21, 2014 7:16 am
Posts: 104
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.


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Wed Apr 29, 2015 4:46 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Wed Apr 29, 2015 5:24 am 
Offline
Member
Member

Joined: Sun Sep 21, 2014 7:16 am
Posts: 104
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?


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Wed Apr 29, 2015 5:35 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Wed Apr 29, 2015 6:09 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
Double-check what you're building - the wiki says not to build libiberty, but instead to build all-gcc and target-libgcc.


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Wed Apr 29, 2015 7:09 am 
Offline
Member
Member

Joined: Sun Sep 21, 2014 7:16 am
Posts: 104
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:
$ ../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.


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Sun May 03, 2015 12:21 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Sun May 03, 2015 1:03 am 
Offline
Member
Member

Joined: Sun Sep 21, 2014 7:16 am
Posts: 104
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.


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Fri May 08, 2015 12:49 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: GCC Cross compiler in Ubuntu 12.04
PostPosted: Fri May 08, 2015 8:24 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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 ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 119 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group