2020年 12月 09日
openSUSE15.2 x86-64 環境でARMのクロスコンパイル
cross-arm-linux-gnueabi-gcc
zypper addrepo https://download.opensuse.org/repositories/home:duwe:crosstools2/openSUSE_Leap_15.2/home:duwe:crosstools2.repozypper refresh
# zypper install cross-arm-linux-gnueabi-gcc
# yast2 & もしくは# yast
opensuse152:~/test # ls /opt/cross/arm-linux-gnueabi -altotal 0drwxr-xr-x 1 root root 64 Dec 8 13:26 .drwxr-xr-x 1 root root 136 Nov 6 03:45 ..drwxr-xr-x 1 root root 92 Dec 6 20:20 bindrwxr-xr-x 1 root root 6 Dec 6 20:20 includedrwxr-xr-x 1 root root 532 Dec 6 20:20 lib
opensuse152:~/test # cat test.c#include <stdio.h>int main(){printf("Hello World\n");return(0);}
opensuse152:~/test # /opt/cross/bin/arm-linux-gnueabi-gcc -o armhello test.ctest.c:1:10: fatal error: stdio.h: No such file or directory1 | #include <stdio.h>| ^~~~~~~~~compilation terminated.opensuse152:~/test #
/opt/cross/arm-linux-gnueabi/include/c++/9.3.0/tr1/*
を
/opt/cross/arm-linux-gnueabi/include/c++/9.3.0/
cross-arm-linux-gnueabi-glibc
opensuse152:~/test # find /opt/cross/ -name "crt1.o"/opt/cross/arm-linux-gnueabi/sys-root/lib/crt1.oopensuse152:~/test #
opensuse152:~/test # /opt/cross/bin/arm-linux-gnueabi-c++ test.c -o testtest.c: In function ‘int main()’:test.c:4:2: error: ‘printf’ was not declared in this scope4 | printf("Hello World\n");| ^~~~~~test.c:2:1: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?1 | #include <stdio.h>+++ |+#include <cstdio>2 | int main()opensuse152:~/test # ls -al test-rwxr-xr-x 1 root root 7976 Dec 8 13:33 testopensuse152:~/test #
opensuse152:~/test # file testtest: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.2.0, not strippedopensuse152:~/test #
openSUSE:Leap:15.2:Update プロジェクト提供の qemu-arm
opensuse152:~/test # qemu-system-arm --versionQEMU emulator version 4.2.1 (openSUSE Leap 15.2)Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developersopensuse152:~/test #opensuse152:~/test # qemu-system-arm -M ?Supported machines are:akita Sharp SL-C1000 (Akita) PDA (PXA270)ast2500-evb Aspeed AST2500 EVB (ARM1176)ast2600-evb Aspeed AST2600 EVB (Cortex A7)borzoi Sharp SL-C3100 (Borzoi) PDA (PXA270)canon-a1100 Canon PowerShot A1100 IS:: 以下略:opensuse152:~/test #
29.2 General qemu-system-ARCH Options
qemu-system-arm • helpQEMU emulator version 2https://helpmanual.io/help/qemu-system-arm/