arm-linuc-gcc-3.4.1交叉编译
(本文是我以前所写,放在此处,以备今后学习查看)
首先要下载arm-linux-gcc-3.4.1.tar.bz2这个压缩包,在linux下解压缩。
接下来设置路径,方法有三:
1.在终端输入:export PATH=$PATH:/usr/local/arm/3.4.1/bin,如果你的解压缩在home下,那就在前面加上/home/.../usr/....,如果输入错误重新输入或者重新打开一个终端即可,完成后在终端输入:arm-linux-gcc -v,如果成功会显示:
Reading specs from /home/magciliu/usr/local/arm/3.4.1/bin/../lib/gcc/arm-linux/3.4.1/specs
Configured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/usr/local/arm/3.4.1 --with-headers=/usr/local/arm/3.4.1/arm-linux/include --with-local-prefix=/usr/local/arm/3.4.1/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.1
现在就可以交叉编译自己的文件了,如编写一个helloworld.c文件,执行arm-linux-gcc helloworld.c -o helloworld,就会生成一个二进制文件了。
这种方法实际上只是设置了一个临时路径,关闭终端后就没有了。
以下还有两种方法,设置后以后都不用设置了,有时间可以尝试一下。
2.在/etc/profile最后添加:
PATH=$PATH:/usr/local/arm/3.4.1/bin
3.在~/.bash_profile最后添加:
PATH=$PATH:/usr/local/arm/3.4.1/bin