I've got a CMake project I'd like to cross-compile for Raspberry Pi zero.
I'm able to compile my code using the gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf
toolchain and run it over Raspberry Pi 3B+, but on the zero I'm getting Illegal instruction
.
I tried to verify that the binary is legit:
pi@raspberrypi:~/mylib $ file mylib.so
mylib.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=478ce6fb9de7f4dfbc87199c3f7618a17afacf9e, with
debug_info, not stripped
What am I doing wrong? I'm invoking CMake with:
CMAKE_DEFINES="$CMAKE_DEFINES -DCMAKE_SYSTEM_NAME=Linux"
CMAKE_DEFINES="$CMAKE_DEFINES -DCMAKE_C_COMPILER=$TOOLCHAIN_PATH/bin/arm-linux-gnueabihf-gcc"
CMAKE_DEFINES="$CMAKE_DEFINES -DCMAKE_CXX_COMPILER=$TOOLCHAIN_PATH/bin/arm-linux-gnueabihf-g++"
cmake ../src -G"Unix Makefiles" $CMAKE_DEFINES