LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-28-2011, 04:22 AM   #1
shone27
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Rep: Reputation: Disabled
[Question] How to compile a gcc compiler for another machine which got no c compiler on it


Hi everyone,

I've searched through net and this forum section for compiling a gcc compiler. Most of people suggest, just d/l the rpm and install it.
I'm wondering if there is a way to simply compile the gcc compiler from another machine?

I've got binutil, mpc, mpfr, and gmp extracted and installed those libraries. I've been trying to compile gcc with configure -target=i686-linux, then make. It ends up with an error message, "can not compute suffix". Is this the correct way to compile a compiler for another machine? and what am I missing here?

If there is anything else I can provide for solving this issue, please let me know.

Thank you for reading my questions

Regards,
Sean

Last edited by shone27; 09-28-2011 at 04:25 AM. Reason: making explicit title
 
Old 09-28-2011, 05:21 AM   #2
Thor_2.0
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,204
Blog Entries: 23

Rep: Reputation: 279Reputation: 279Reputation: 279
Intersting challenge. The way I'd go about it is simple: get Knoppix, boot from it. Arrange/settle in and wget/install your packages, including gcc. Compile on that machine. For the config, use --prefix as parameter, where the value is the mounted partition where the package has to go to:

Quote:
./configure --prefix=/media/sda3
...that should instruct the config script to send the output to the target harddrive.

Good luck

Thor
 
1 members found this post helpful.
Old 09-28-2011, 05:25 AM   #3
snooly
Member
 
Registered: Sep 2011
Posts: 124

Rep: Reputation: Disabled
How come you don't want to download and install a compiler? Doing a cross-compile isn't really an easy task for a newbie.
 
Old 09-28-2011, 05:40 AM   #4
shone27
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Thor_2.0 View Post
Intersting challenge. The way I'd go about it is simple: get Knoppix, boot from it. Arrange/settle in and wget/install your packages, including gcc. Compile on that machine. For the config, use --prefix as parameter, where the value is the mounted partition where the package has to go to:



...that should instruct the config script to send the output to the target harddrive.

Good luck

Thor
Thank u for ur reply, Thor. I'll try it out, when I'm at work tomorrow.

To Snooly,
It always bothers me as how a compiler works, I simply thought this might be a good opportunity to understand it more.
 
Old 09-28-2011, 05:45 AM   #5
snooly
Member
 
Registered: Sep 2011
Posts: 124

Rep: Reputation: Disabled
I think this task is too difficult if you don't understand how a compiler works. Try something easier like download a pre-built compiler, and the source code for some software. Try building some much smaller simpler software first with your pre-built compiler. Then try writing your own software and compiling that. If you can do these things, you are a small step along the way to doing this cross-compile task.
 
Old 09-28-2011, 08:31 AM   #6
shone27
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by snooly View Post
I think this task is too difficult if you don't understand how a compiler works. Try something easier like download a pre-built compiler, and the source code for some software. Try building some much smaller simpler software first with your pre-built compiler. Then try writing your own software and compiling that. If you can do these things, you are a small step along the way to doing this cross-compile task.
Hi Snooly,

Thank you for your advice, I've written a several programs for access smbios and pci devices for testing storages. As most of our diagnostics are built for linux platform, so I'm trying to get myself more familiar with the linux kernel as well as the compiler. I need something more than just keeping on making some software. Any advices on bit advanced practice is much appreciated

Regards,
Sean
 
Old 09-28-2011, 08:36 AM   #7
snooly
Member
 
Registered: Sep 2011
Posts: 124

Rep: Reputation: Disabled
A compiler is just another big piece of software. So you can practice by building any big piece of software. It's easy to do nowadays because of the "./configure; make; make install" commands which automatically configure and build the software.

So if you can build some big piece of software and it works okay, then you can build a compiler and it will work okay too. You can install a pre-built compiler in /usr/bin and put the one you built in /usr/local/bin. Then by manipulating your path you can choose which one to use.

After you can build a compiler that works on your local machine, then you can read up on cross-compiling, and see if you can build a compiler on one machine that will work on a different type of machine. But it's tricky, and will take a fair bit of research. Good luck!
 
1 members found this post helpful.
Old 09-28-2011, 08:39 AM   #8
shone27
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by snooly View Post
A compiler is just another big piece of software. So you can practice by building any big piece of software. It's easy to do nowadays because of the "./configure; make; make install" commands which automatically configure and build the software.

So if you can build some big piece of software and it works okay, then you can build a compiler and it will work okay too. You can install a pre-built compiler in /usr/bin and put the one you built in /usr/local/bin. Then by manipulating your path you can choose which one to use.

After you can build a compiler that works on your local machine, then you can read up on cross-compiling, and see if you can build a compiler on one machine that will work on a different type of machine. But it's tricky, and will take a fair bit of research. Good luck!
Thanks a lot, Snooly. I'll practice with what you suggest here

Regards,
Sean
 
Old 09-28-2011, 01:15 PM   #9
wpeckham
Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 765

Rep: Reputation: 172Reputation: 172
Compile me a compiler

I like the attitude. IT may not be the easiest way, but if you want to learn how to do things jumping in and cross-compiling is certainly one way to start.

I have to agree that it may not be the most productive way, and starting on smaller and native projects makes good sense.

Most of my cross-compile projects were given up because someone made a native port quicker than I could work through the issues involved. It can be a minefield of complications. While that makes it quite a learning experience, I cannot recommend it: it can be anything other than painless!
 
Old 09-28-2011, 07:32 PM   #10
shone27
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
I like the attitude. IT may not be the easiest way, but if you want to learn how to do things jumping in and cross-compiling is certainly one way to start.

I have to agree that it may not be the most productive way, and starting on smaller and native projects makes good sense.

Most of my cross-compile projects were given up because someone made a native port quicker than I could work through the issues involved. It can be a minefield of complications. While that makes it quite a learning experience, I cannot recommend it: it can be anything other than painless!
Thank you for your encouragement. I was almost about to give up on cross compiling before getting suggestions from you guys.
Now, I feel that I can keep on doing this
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Compiler Benchmarks Of GCC, LLVM-GCC, DragonEgg, Clang LXer Syndicated Linux News 0 11-08-2010 05:11 PM
fortran compiler that can compile progs on a linux machine, but execute on windows XP pbeierle Linux - Software 3 01-07-2010 03:04 PM
How to compile gcc when there is no c compiler installed!? So confused... chuckycharms Linux - Newbie 18 11-17-2009 10:33 AM
Installing gcc 2.95 compiler in a RH 3.2.2-5 machine Priyakrishnan Linux - Software 13 02-28-2007 08:09 AM
compile a compiler without a compiler? lackluster Linux - General 18 01-02-2003 07:55 PM


All times are GMT -5. The time now is 07:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration