stdio.h error when creating a binary for C code to target x86

34 Views Asked by At

I'm using gem5 to target an x86 ISA. I'm currently using a MacOS and installed asahi linux because gem5 seems to work better on linux.

When I compile C code that I wrote using the command "gcc helloworld.c" and run "file binary", I get "ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked". Since I'm targeting an x86 machine, I want the ISA to be x86-64 instead of ARM aarch64, so I tried cross compiling x86_64-linux-gnu-gcc.However, when I try running "x86_64-linux-gnu-gcc -static -o your_x86_64_executable helloworld.c", I get the following error:

helloworld.c:1:10: fatal error: stdio.h: No such file or directory 1 | #include <stdio.h> | ^~~~~~~~~ compilation terminated.

I'm assuming this means there is no stdio.h for some reason. So I tried running "cd $(x86_64-linux-gnu-gcc -print-file-name=include)" and "ls" to check the x86_64-linux-gnu include directory and found out that there is no stdio.h in this directory. Why would this be the case and what can I do to fix this?

0

There are 0 best solutions below