GCC cross compiler for x86_64-elf

Hi,
I am building GCC cross compiler for x86_64-elf
for that a have followed steps,

  1. mkdir build-gmp build-mpfr

  2. cd build-gmp

  3. ../gmp-4.2/configure --prefix=/usr/local

  4. make all install

  5. make check

6.cd ../build-mpfr

  1. ../mpfr-2.3.2/configure --prefix=/usr/local/

  2. make all install

  3. export LD_LIBRARY_PATH= /usr/local/lib

----------------------------------------------------------------------

  1. export PREFIX=/usr/cross

  2. export TARGET=x86_64-elf

  3. cd /usr/src

  4. mkdir build-binutils build-gcc

  5. cd ../build-binutils

  6. ../binutils-2.18/configure --target=$TARGET --prefix=$PREFIX --disable-nls

  7. make all

  8. make install

  9. export PATH=$PATH:$PREFIX/bin

  10. cd ../build-gcc
    ../gcc-4.3.2/configure --target=$TARGET --prefix=$PREFIX --disable-nls
    --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-mpfr=/usr/local

  11. make all-gcc install-gcc

------Porting new library------

  1. cd build-newlib/

  2. ../newlib-1.17.0/configure --prefix=$PREFIX --target=$TARGET

  3. make all install

-------------Rebuild GCC with headers......
using the --with-headers option to tell GCC where to find the headers of new C library.

  1. ../gcc-4.3.2/configure --target=$TARGET --prefix=$PREFIX --disable-nls
    --enable-languages=c,c++ --with-headers=/usr/cross/x86_64-elf/include --with-gmp=
    /usr/local --with-mpfr=/usr/local

  2. make all-gcc

  3. make install-gcc

It is successfuly installed. But when i am compiling simple helloworld program it is giving error as

[root@vm-centos12 build-gcc]#x86_64-elf-gcc hello.c
/usr/cross/lib/gcc/x86_64-elf/4.3.2/../../../../x86_64-elf/bin/ld: crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status

I have searched for crt0.o file but this file is not present in gcc installed folder.

Please tell me where is the problem and steps that i followed are correct or not.

I am very much thankful to you.

Regards :confused:
Mandar.

You cannot run a 64-bit application on 32-bit hardware. If you did, in fact, install the compiler on the 64-bit host, you must also install the "run time" libraries. check the documentation for that. The "run time" libraries must be compiled for 64-bit hardware, so either they are cross-compiled, or compiled statically on the target host.

Yes sir,
I am not executing 64-bit application. I want to compile only.
Now the proble is of C Runtime library, To resolve this i have installed newlib library, So i got header files for new compiler but not getting library files ie libgcc.a libc.so etc.
I am cross compiling the library by giving target as x86_64-elf.

For installing i Followed steps-

cd build-newlib/

../newlib-1.17.0/configure --prefix=/usr/cross --target=x86_64-elf

make all install

-------------Rebuild GCC with headers......

../gcc-4.3.2/configure --target=x86_64-elf --prefix=/usr/cross --disable-nls --enable-languages=c,c++ --with-headers=/usr/cross/x86_64-elf/include --with-gmp= /usr/local --with-mpfr=/usr/local --with-newlib=/usr/crsoss/x86_64-elf/lib

make all-gcc

make install-gcc

So problem is, i am not getting C library files for creating object file.
please tell me where i am wrong.

Thanking you,
Mandar.

[quote=mandar123;302272569]

[root@vm-centos12 build-gcc]#x86_64-elf-gcc hello.c 
/usr/cross/lib/gcc/x86_64-elf/4.3.2/../../../../x86_64-elf/bin/ld: crt0.o: No such file: No such file or directory 
collect2: ld returned 1 exit status 

See if the crt0.o file is anywhere in

/usr/cross/lib/gcc/x86_64-elf/

using find.

find /usr/cross/lib/gcc/x86_64-elf -type f -name crt0.o -ls

Yes i tried this but this file is not found.
So i searched for this error and somewhere i got idea to copy crt0.o from target machine(64-bit) in /usr/cross/x86_64-elf/lib.
Then this "crt0.o file not found" is resolved but getting another errors for "*.o" files,
means it is not getting C library files.

After installation in my system only libc.a, libm.a, libg.a, libnosys.a files are created in /usr/cross/x86_64-elf/lib directory.

I am not getting whether i missed any option for library files while configuring and installing newlib / GCC.(steps i followed are in previous post)

Please tell me what i have to do for this problem.

Thanking you,
Mandar.
:confused:

I do not have specific experience with this, but as I said in my first post, in order to make any cross compiler work, you must also install all cross-platform libraries, header files, etc. This includes the "stub object" .o files that gcc is currently requiring. Again, look at the documentation carefully to determine what steps are required for installing the support libraries and object files.

However you compile it, the linker still needs to find the static or dynamic objects which will be used to ultimately execute the program. This means you have to have all 64-bit libraries installed upon which the program depends. Apparently, then, before you cross-compile a program, you must install all supporting libraries, or cross compile them. Installing would be much easier.