Installing gcc on linux without c compiler

前端 未结 5 1725
轻奢々
轻奢々 2021-01-04 02:20

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.

5条回答
  •  醉话见心
    2021-01-04 02:55

    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.

提交回复
热议问题