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找不到的錯誤

2)編譯時會報錯:error: stray "\357" not in program. 一般是#include <iostream>等include文件的語法中混入了非ASCII字符。手動刪掉#include行重新輸入即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM