How to install i386 gcc cross compiler on linux - linux

Hi, how can i download i386 elf cross compiler on linux
i need:
i386-elf-gcc
i386-elf-ld
what commands i need to write in to cmd to get this packages?
Please help me!

I think you could create your own binary cross compiler basing on sources from:
https://crosstool-ng.github.io/
The crosstool-ng are sources of the cross toolchain which you can configure on your own to achieve gcc and ld. The configuration process is similar to the configuration of linux kernel. It just uses "menuconfig" method for configuring all the things. Then you run compilation of this project and if everything go fine you will get cross toolchain.

Related

Compileing GNU binutils - some questions

I am trying to compile the GNU binutils for PowerPc on my x86-64 Pc. I'm not trying to cross compile them (got the cross compiler version from the AUR), I'm trying to compile the on my pc to use them on the other(It has no network etc just an SD-card). Anyways I have downloaded the tar file and tried to run ./configure but I wasn't sure what options to use and couldn't any proper documentation... For example what to I need to set $CC to the powerpc-linux-gnu-gcc compiler or do i need to set this as $CC_FOR_TARGET or both idk. I found out --prefix is the output output folder but idk anything else. Pl help
Cross compiling can be difficult if you are not familiar with the process. I'd recommend Debian and Ubuntu as they have a very good set of cross compilers prepackaged you can get with apt install gcc-powerpc64le-linux-gnu.
Alternatively, you can download cross compilers from: https://toolchains.bootlin.com/
There is information about the config options available by running ./configure --help
The relevant option in this situation is:
--host=HOST cross-compile to build programs to run on HOST [BUILD]
For 32bit ppc:
./configure --host=powerpc-linux-gnu

Issue building Linaro GDB for aarch64 on x86_64 host

I downloaded the gdb sources from https://launchpad.net/gdb-linaro/.
I want to build the gdb for aarch64.
As mentioned in README file I set CC to the cross compiler that I have
CC=aarch64-linux-gnu-gcc
./configure --host=aarch64
However this doesn't seem right as this sets the target to "aarch64-unknown-none"
And later make fails as below
*** BFD does not support target aarch64-unknown-none.
I am not sure how to pass the correct target name required to cross compile gdb on my system.
Any suggestions will help! :)
Thanks,
MS
It seems below does the job.
./configure --host=aarch64-linux-gnu
Thank you for the comments..
BR,
MS

Can gcc produce binary for Arm without cross compilation

Can we configure gcc running on intel x64 architecture to produce binary for ARM chip by just passing some flags to gcc and not using a cross compiler.
Short: Nope
Compiler:
gcc is not a native crosscompiler, the target architecture has to be specified at the time you compile gcc. (Some exceptions apply, as for example x86 and x86_64 can be supported at the same time)
clang would be a native crosscompiler, and you can generate code for arm by passing -target=arm-linux-gnu, but you still cant produce binaries, as you need a linker and a C-library too. Means you can run clang -target=arm-linux-gnu -c <your file> and compile C/C++ Code (will likely need to point it to your C/C++ include paths) - but you cant build binaries.
Rest of the toolchain:
You need a fitting linker and toolchain too, both are specific to the architecture and OS you want to run at.
Possible solutions:
Get a fitting toolchain, or compile your own. For arm linux you have for ex. CrossToolchains if you are on debian, for barebones you can get a crosscompiler from codesourcery.
Since you were very vague, its not possible to give you a clearer answer

Cross compiling libSDL

I'm trying to cross-compile libSDL version 1.2 for a custom made, debian based Linux system. The toolchain I'm using is already configured properly so that I just run gcc/g++ on my the desired code and the resulting output is compatible with the target machine.
When I run ./configure --help in the libSDL source directory, I see that I can basically just set some environment variables to point to my cross-compiler.
However, I also see the following options:
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
I looked into the configure.in, build-scripts/config.sub, and build-scripts/config.guess files but couldn't really figure out how it works.
Are these options required? If not, is it a good idea to use them?
With autotools, --build is what you are building on and --host is what you want it to run on (there's also --target, but that's only important if what you're compiling is itself a compiler). Autotools will generally figure out --build on their own, so don't specify it if you don't have to (but look in /usr/lib/gcc to see what your compiler probably thinks --build should be)
So, eg, if you're building for i686 on x86_64, do
./configure --host=i686-linux-gnu
(And use the -m32 options in CFLAGS, etc., but it sounds like you already have that ready.)
Whereas if you're building for x86_64 on i686, do
./configure --host=x86_64-linux-gnu
(You can build for all kinds of crazy hosts: rs6000-ibm-aix, sparc-sun-solaris, mips-idt-ecoff, etc..., assuming you have the appropriate gcc cross-compilers installed...)
GNU's page on it is here:
http://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html

Installing gcc on linux without c compiler

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.
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.
It depends on the distribution, if it's based on debian or some other of the big ones you can install gcc through apt-get or similar tool.
If it's a more basic system you need to compile gcc yourself on another computer and copy it over. It will be easiest if you have another computer with the same architecture (i386, arm or x86_64 for example).
I think that you might want to compile it statically also, so that you don't have dependencies on external libraries.
How do you plan to get all the source code needed for GCC loaded onto your machine? Could you mount the ISO image onto this machine and install from there?
Since you are using Endian Firewall, see "Building a development box" at the following link:
http://alumnus.caltech.edu/~igormt/endian/tips.html
If it's a debian based distribution, you can use
sudo apt-get install gcc
Note: maybe you must change "gcc" by a specific version of the debian package.

Resources