Page 1 of 1

Build cross compiler but when compiling include error linux

Posted: Wed May 24, 2017 2:15 am
by yerri07
I build a cross compiler i successfully installed but when compiling include error appearing.
$ i686-elf-gcc main.c -o main
main.c:1:10: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^~~~~~~~~
compilation terminated.


I installed in $HOME/opt/cross when i run command i686-elf-gcc main.c -o main
Error command not found

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 2:21 am
by mallard
You obviously haven't ported/written a C standard library for your OS/kernel. Do you think the functions in "stdio.h" will "magically" know how to operate your device/file I/O implementation?

Remove the "#include" and see which functions are needed. Implement them. Problem solved.

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 2:50 am
by yerri07
I didn't created the code for Kernel . i just wanted to test the gcc is working or not?. When i compiled without header got


Error command not found

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 2:57 am
by davidv1992
You seem to be missing the main point of the cross compiler. It is build such that it does depend on any external runtime. In particular, this means that it is completely unsuited for building programs for your current OS, as it misses the runtime support for that.

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 3:18 am
by yerri07
I know it is not intended for the current Os. My question is Not able to compile and command not found errors

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 3:28 am
by mallard
"$HOME/opt/cross" is probably not in your PATH. "stdio.h" is part of the C standard library.

If that doesn't give you enough information to solve your problems, you lack the prerequisite knowledge and experience required for OS development.

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 4:20 am
by yerri07
I know stdio.h is the c library . Any way i know how to compile Kernel and what to do. I thought c library are installed too, i found those are not installed in opt/cross folder.


Any way thanks for the reply and concern. Have a great day

Re: Build cross compiler but when compiling include error li

Posted: Wed May 24, 2017 4:44 am
by mallard
yerri07 wrote:i found those are not installed in opt/cross folder.
Correct. They don't exist by "magic". You must create them (or the bits of them that you need).