第一步:
在终端输入

sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf

命令执行完后交叉编译的gcc和g++就安好了,这一步网上有很多人给的步骤非常繁琐。其实根本不需要。
第二步:
生成可执行文件
先写一个cpp,然后

arm-linux-gnueabihf-g++ helloworld.cpp -o helloworld_arm

第三步:
将这个可执行文件放到树莓派里。
然后给权限

chmod   777   helloworld_arm

完成,现在就可以在树莓派上直接./helloworld_arm执行了。

10-07 14:54