[SOLVED] [Question] How to compile a gcc compiler for another machine which got no c compiler on it
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[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
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.
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.
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.
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
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!
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
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!
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.