Page 1 of 1

GCC cross compiler setting up. No includes files in inc dir

Posted: Mon Oct 24, 2022 6:56 am
by buridan
Hi!

I tried to setting up gcc cross-compilation enviroment with this tutorial: https://wiki.osdev.org/GCC_Cross-Compiler
But after all these steps, I have a problem:
There is no include files in dir: /home/$(username)/opt/cross/include/
So when I try to include string.h header, I have a problem.

I am using this script:

Code: Select all

ARG_PREFIX ="$HOME/opt/cross"
ARG_TARGET =i686-elf
ARG_GCC_VERSION="9.5.0"

cd build-gcc
echo "Start building gcc{$ARG_GCC_VERSION, $ARG_TARGET}"
../deps/gcc-$ARG_GCC_VERSION/configure \
	--target=$ARG_TARGET \
	--prefix=$ARG_PREFIX \
	--disable-nls \
	--enable-languages=c,c++ \
	--without-headers

make all-gcc
make install-gcc
make all-target-libgcc
make install-target-libgcc
#make install-gcc
cd ..
I don't see any error in make logs(https://drive.google.com/file/d/1LDaaOz ... sp=sharing)

Re: GCC cross compiler setting up. No includes files in inc

Posted: Mon Oct 24, 2022 7:11 am
by eekee
Doesn't string.h come from the standard library, libc? libc is separate from the compiler.

Re: GCC cross compiler setting up. No includes files in inc

Posted: Mon Oct 24, 2022 8:24 am
by iansjack
That's not an error. There should be no include files. You supply your own when you create libraries.

Re: GCC cross compiler setting up. No includes files in inc

Posted: Mon Oct 24, 2022 9:43 am
by Barry
When you build GCC and Binutils you can specify a target, in your case i686-elf. Both of those programs have a known set of targets that have different settings, among them an include directory. This is the directory that is searched if you do #include <something.h>. i686-elf doesn't have one by default, but GCC can provide some inbuilt headers still - see gcc/include/ in your build directory. You get given headers like stdint, stddef, stdarg that don't rely on the C library i.e. they don't actually link to anything, just provide definitions. string.h requires libc functions e.g. memcpy() and as such, you have to provide that header with your libc. To do this, either make your own libc or use a publicly available one like newlib.

Thanks,
Barry