I am trying to compile some kernel code for a raspberry pi 3 from a x86 computer using the aarch64 cross compiler in one of my source files I require stdint.h however when I try to compile it fails saying
>make
rm kernel8.elf *.o >/dev/null 2>/dev/null || true
rm -rf *.o *.img *.elf
aarch64-linux-gnu-gcc -Wall -c start.s -o start.o
aarch64-linux-gnu-gcc -Wall -c delays.c -o delays.o
In file included from gpio.h:4:0,
from delays.c:26:
/usr/lib/gcc/aarch64-linux-gnu/7/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^~~~~~~~~~
compilation terminated.
make: *** [Makefile:15: delays.o] Error 1
I am running Fedors 26 and have used
sudo dnf install *aarch64*
so I have all the appropriate packages or should have.
I would suggest to use the latest Linaro toolchain for x86: I have had a couple of issues in the past with ARM cross-compilers provided with mainstream Debian/Ubuntu.
Using the following stdint.c example:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
printf("The size of an uint32_t is %d.\n", sizeof(uint32_t));
return EXIT_SUCCESS;
}
mkdir -p /opt/linaro
wget https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-i686_aarch64-linux-gnu.tar.xz
tar Jxvf gcc-linaro-7.2.1-2017.11-i686_aarch64-linux-gnu.tar.xz -C /opt/linaro
/opt/linaro/gcc-linaro-7.2.1-2017.11-i686_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -o stdint stdint.c
The compilation should succeed, and you should get a working AARCH64 executable:
readelf -h stdint
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x1
Entry point address: 0x4003f0
Start of program headers: 64 (bytes into file)
Start of section headers: 4872008 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 6
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 36
If you have an x86_64 development PC, using the x86_64 version of the Linaro toolchain would of course be preferable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.