Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
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.
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 ..
Doesn't string.h come from the standard library, libc? libc is separate from the compiler.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
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.