you can use arm-linux-gnueabihf-gcc hello.c -o hello command. And before you should install arm-linux-gnueabihf-gcc in your linux system .
here is full sample that work for me
Answer from reza rezaee on Stack OverflowHello everyone.
I run gentoo for development and use the crossdev tools to generate an arm cross compiler.
I'm having problems finding a version of gcc that behaves when compiling code for armv7l. (gnueabihf).
11.2.X seems to have pie problem (I don't get what pie is, I mean I do conceptually but I don't understand why it is suddenly enabled by default)
I was using 10.5, but gnueabihf wasn't working so I dropped the hf and it worked, but shouldn't it work with Cyclone V?
And I'm confused about how the arch is specified.
Right now I'm using arm-linux-gnueabi, but I wonder if I should be using arm-none-linux-gnueabihf...
Can you guys suggest a known working version of the cross arm tools.
ARM seems to recommend 7.5 and that is way too old for modern linux.
I ended up compiling GCC from source, following this post. I didn't need all of the steps (I compiled everything using GCC 8 instead of compiling GCC 6.3 first, and I didn't edit any source files.)
I posted a Dockerfile with all build steps on GitHub.
The architecture of the executables produced is correct now, but I can't test it on target yet to check if it actually runs.
By default, newer GCC versions do not create correct binaries for ARMv6. Even though you pass the correct -mcpu= flag to gcc, it will create startup code for the newer ARMv7 architecture. Running them on your RasPI Zero will cause an "Illegal Instruction" exception.
this info is mentioned here https://github.com/Pro/raspi-toolchain