先裝JRE, sudo apt-get install sun-java6-jre
下載eclipse C++的壓縮包,解壓開袋即食
新建項目,右鍵屬性,C/C++bulid,Setting,Configuration新添加一個,Command處填寫arm-linux-gcc,編譯,,,
又出現arm-linux-gcc not found ! 明明arm-linux-gcc -v 沒問題!
殺手锏,gedit /etc/profile /etc/environment /etc/bash.bashrc ~/.bashrc ~/.profile
全都加上export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/opt/bin:/usr/local/bin:/usr/local/arm/4.3.2/bin"
ok~
but~還有新的問題:
**** Build of configuration arm for project hello ****
make all
Building file: ../src/hello.c
Invoking: GCC C Compiler
/usr/local/arm/4.3.2/bin/arm-linux-gcc -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/hello.d" -MT"src/hello.d" -o"src/hello.o" "../src/hello.c"
Finished building: ../src/hello.c
Building target: hello
Invoking: GCC C Linker
gcc -o"hello" ./src/hello.o
/usr/bin/ld: ./src/hello.o: Relocations in generic ELF (EM: 40)
./src/hello.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [hello] Error 1
產生錯誤:
could not read symbols: File in wrong format,
找到這個hello.o,執行file hello.o, 顯示:ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped,沒錯阿
仔細看日志,
arm-linux-gcc已經編譯處了。0文件,參數是
arm-linux-gcc
-O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/hello.d" -MT"src/hello.d" -o" o文件名 原文件名,難道是參數有錯?還有一點可能,出錯明顯是link過程產生的
看日志,/usr/bin/ld: ./src/hello.o: Relocations in generic ELF (EM: 40),,,居然用這個ld來連接,,,而沒用我的arm-linux-ld,不報錯才怪,但是,eclipse在那裡設置ld呢,,,
猜想沒錯,工程屬性設置中,
Linker和Assembler的命令分別換成/usr/local/arm/3.4.1/bin/arm-linux-gcc和
/usr/local/arm/3.4.1/bin/arm-linux-as
這樣link中間.o文件文件的時候就OK了。