C++在ARM Linux下的交叉编译

  • 安装交叉编译环境
    • 根据板子的文档,安装ubuntu12.04
    • tools/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 解压下载好的编译工具
    • 将编译工具的bin目录添加到环境变量
      • sudo gedit /etc/profile 
      • export PATH=$PATH:/home/tl/arm-2009q1/bin 
      • source /etc/profile 
    • 重启虚机,查看版本号
      • arm-none-linux-gnueabi-gcc -v 
      • 出现gcc sversion 4.3.3版本号表明交叉编译环境安装成功
  • 编译cpp源文件
    • arm-none-linux-gnueabi-g++ test_3.cpp -o test_3
  • 在ARM板下运行
    • chmod +x test_3
    • ./test_3

注:

1)use g++ to compile C++ programs, it'll link in the standard c++ library. gcc will not. gcc will also compile your code as C code if you give it a .c suffix. Give your files a .cpp suffix. 使用-g++编译cpp文件。如果使用gcc,会出现std找不到的错误

猜你喜欢

转载自www.cnblogs.com/ryu-manager/p/10456015.html