Page 1 of 1

Cross Compiler

Posted: Mon Mar 02, 2015 10:22 am
by LoIulia
Hello, I've been trying to build my own cross compiler (on xubuntu) but i'm getting an infintie series of errors... I tried everything: every tutorial on internet, automated script or pre-built packages, but nothing works... what can I do? thank in advance
PS he error I can't solve is that gcc doesn-t find zlib.h, even if it present in my system. it occures during the execution of "mak all-gcc"

Re: Cross Compiler

Posted: Mon Mar 02, 2015 10:44 am
by Combuster
Here's the tutorial you should have tried: GCC Cross-Compiler. If that actually does give errors, you should post them along with the exact commands you used.

Re: Cross Compiler

Posted: Thu Mar 05, 2015 4:03 pm
by LoIulia
sorry, if I reply you so late, but I had a lot of problem, so I couldnt use my pc :( .
this is the first :( strange thing I have noticed during configuration:

Code: Select all

checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for i686-elf-cc... no
checking for i686-elf-gcc... no
checking for i686-elf-c++... no
checking for i686-elf-g++... no
checking for i686-elf-cxx... no
checking for i686-elf-gxx... no
checking for i686-elf-gcc... no
checking for i686-elf-gcj... no
checking for i686-elf-gfortran... no
checking for i686-elf-gccgo... no
checking for ar... no
checking for i686-elf-ar... no
checking for as... no
checking for i686-elf-as... no
checking for dlltool... no
checking for i686-elf-dlltool... no
checking for ld... no
checking for i686-elf-ld... no
checking for lipo... no
checking for i686-elf-lipo... no
checking for nm... no
checking for i686-elf-nm... no
checking for objdump... no
checking for i686-elf-objdump... no
checking for ranlib... no
checking for i686-elf-ranlib... no
checking for readelf... no
checking for i686-elf-readelf... no
checking for strip... no
checking for i686-elf-strip... no
checking for windres... no
checking for i686-elf-windres... no
checking for windmc... no
checking for i686-elf-windmc... no
and, after some minute after I typed make all-gcc it stops with this text:

Code: Select all

checking command to parse nm output from gcc  -m32 object... failed
checking how to run the C preprocessor... /lib/cpp
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc  -m32 supports -fno-rtti -fno-exceptions... no
checking for gcc  -m32 option to produce PIC... -fPIC -DPIC
checking if gcc  -m32 PIC flag -fPIC -DPIC works... yes
checking if gcc  -m32 static flag -static works... no
checking if gcc  -m32 supports -c -o file.o... yes
checking if gcc  -m32 supports -c -o file.o... (cached) yes
checking whether the gcc  -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... nochecking command to parse nm output from gcc  -m32 object... failed
checking how to run the C preprocessor... /lib/cpp
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc  -m32 supports -fno-rtti -fno-exceptions... no
checking for gcc  -m32 option to produce PIC... -fPIC -DPIC
checking if gcc  -m32 PIC flag -fPIC -DPIC works... yes
checking if gcc  -m32 static flag -static works... no
checking if gcc  -m32 supports -c -o file.o... yes
checking if gcc  -m32 supports -c -o file.o... (cached) yes
checking whether the gcc  -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9745: recipe for target 'configure-zlib' failed
make: *** [configure-zlib] Error 1
I think the error could be related to this fantomatic m32... I googled it but I didn-t find nothing.
thanks in advance

Re: Cross Compiler

Posted: Thu Mar 05, 2015 6:44 pm
by SoulofDeity
Looks to me like you weren't following directions and skipped the part where you add '$PREFIX/bin' to your PATH before compiling.

Re: Cross Compiler

Posted: Fri Mar 06, 2015 1:15 am
by iansjack
As Combuster says, you need to post the exact commands that you use; otherwise the logs are useless. Also, more details of your host environment would help: version of Ubuntu, versions of gcc and bin utils, is your host 64-bit and, if so, do you have the 32-bit compatibility libraries installed.

More information please!

Re: Cross Compiler

Posted: Fri Mar 06, 2015 9:42 am
by LoIulia
I'm running xubuntu 14.04 64 bit my gcc version is 4.9.1 and I-m trying to build the same version with binutils 2.24, in folder $HOME/src/gcc. about 32 bit libraries, I don't now how to check if they're installed. can you tell me how to do_
I did what the tutorial said; I typed:

Code: Select all

export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
than:

Code: Select all

mkdir build-gcc
cd build-gcc
../configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --enable-multilib
make all-gcc

Re: Cross Compiler

Posted: Fri Mar 06, 2015 9:54 am
by iansjack
OK. So you are trying to build a 32-bit compiler. Can we assume that you have already built the corresponding binutils? The question about 32-bit libraries is probably a red herring, so you can ignore that for now. Originally you had a problem with zlib; it may be that you need to install zlib-devel (no idea if that's what it's called on Ubuntu, but there should be some package like that).

Also, I'm not sure that the "--enable-multilib" switch is correct; where did that come from?

Re: Cross Compiler

Posted: Fri Mar 06, 2015 1:10 pm
by LoIulia
zlib is correctly updated to the last version, I tried to update every related package (zlib-bin, zlib1g, zlib1g-dev, zlibc)
--enable-multilib flag should be on by default, but during configuration it told me that there was a problem and that this flag were probabily disabled.
Do you have any idea?

Re: Cross Compiler

Posted: Fri Mar 06, 2015 3:25 pm
by jnc100
1) You should probably build in a location completely outside the gcc source tree e.g. ~/src/build-gcc where the source is in ~/src/gcc-4.x.x (rather than a subdirectory of the source tree).

2) Can we assume that the cross binutils is correctly built and works (i.e. you can execute i686-elf-ld from any directory and it works as expected)?

3) You need all the appropriate dependencies (for ubuntu: apt-get install libgmp3-dev libmpfr-dev libisl-dev libcloog-isl-dev libmpc-dev texinfo)

4) If the above are all resolved, you should delete the source and build directories, re-extract the source and compile again with the exact commands as per the wiki page.

Regards,
John.