LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [Question] How to compile a gcc compiler for another machine which got no c compiler on it (http://www.linuxquestions.org/questions/linux-newbie-8/%5Bquestion%5D-how-to-compile-a-gcc-compiler-for-another-machine-which-got-no-c-compiler-on-it-905381/)

shone27 09-28-2011 04:22 AM

[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

Thor_2.0 09-28-2011 05:21 AM

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

snooly 09-28-2011 05:25 AM

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.

shone27 09-28-2011 05:40 AM

Quote:

Originally Posted by Thor_2.0 (Post 4484265)
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.

snooly 09-28-2011 05:45 AM

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.

shone27 09-28-2011 08:31 AM

Quote:

Originally Posted by snooly (Post 4484295)
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

snooly 09-28-2011 08:36 AM

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!

shone27 09-28-2011 08:39 AM

Quote:

Originally Posted by snooly (Post 4484475)
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

wpeckham 09-28-2011 01:15 PM

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!

shone27 09-28-2011 07:32 PM

Quote:

Originally Posted by wpeckham (Post 4484644)
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 :)


All times are GMT -5. The time now is 03:51 AM.