When I compile code on a Raspberry Pi running the latest Bookworm release, it won’t run on a Raspberry Pi with Buster. It returns cannot execute binary file: Exec format error
. Why?
Compile on Bookworm:
pi@Bookworm:~ $ gcc -o hello_world hello_world.c
pi@Bookworm:~ $ ./hello_world
Hello world!
pi@Bookworm:~ $ scp hello_world [email protected]:/home/pi/
pi@Bookworm~ $ cat /etc/issue
Debian GNU/Linux 12 n l
pi@WBookworm:~ $ gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Then run it on Buster:
pi@Buster:~ $ ./hello_world
-bash: ./hello_world: cannot execute binary file: Exec format error
pi@Buster:~ $ cat /etc/issue
Raspbian GNU/Linux 10 n l
pi@Buster:~ $ gcc --version
gcc (Raspbian 8.3.0-6+rpi1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.