Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing gcc on linux without c compiler

Tags:

linux

gcc

How can I install gcc on a system that have not any c compiler? this system is a linux base firewall and have not any c compiler.

like image 374
hamSh Avatar asked Aug 13 '10 11:08

hamSh


People also ask

Is GCC compiler only for C?

GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++.

Do I need compiler in Linux?

so can a linux distribution work perfectly without a c compiler? In general, yes. There are (or were) closed source programs though which are very low level and thus need to adapt to the kernel version by compiling some glue code.


1 Answers

I guess you a have an appliance running Linux and shell-access, but neither a package manager nor a compiler is installed.

So, you need to cross-compile gcc and the whole toolchain (at least binutils) - this is quite simple, because the ./configure scripts of gcc, binutils, gdb etc. support cross-compiling with the --target= option. So all you have to do is to find out the target architecure (uname helps) and then download, unpack the gcc sources on a linux-host and run ./configure --target=$YOUR_TARGET.

With this, you now can build a cross-compiler gcc - this still runs on your host, but produces binaries for your target (firewall appliances).

This may already be sufficient for you, a typical desktop PC is much faster than a typical appliance, so it may make sense to compile everything you need on the Desktop PC with the cross-compiler and cross-binutils.

But if you really wish to do so, you can now also use your cross-compiler to compile a gcc running on your target (set this as --host= option) and compiling for your target (set this as --target option).

You can find details about allowed host/targets and examples in the gcc documentation: http://gcc.gnu.org/install/specific.html.

like image 83
IanH Avatar answered Sep 24 '22 07:09

IanH