-
arm-linux-
gcc
交叉工具链的安装和使用
分类:
linux
内核
工具使用
2013-01-18 01:01
2295
人阅读
评论
(0)
收藏
举报
1
、安装
arm-linux-
gcc
交叉工具链
[root@localhost Denny]# ls
Desktop
gcc
kernel
modules
shell
实
验
tftp
安装包
wireshark
软件包
at_remind.c
file
gdb
makefiles
samba
安装
包
smb
test
wireless
[root@localhost Denny]#
tar
zxvf
-C
/
// -C
参数指的是解
压到根目录下面
[root@localhost /]# cd /usr/local/
[root@localhost local]# ls
arm
bin
etc
games
include
lib
libexec
sbin
share
src
[root@localhost local]# cd arm/4.3.2/
arm-none-linux-gnueabi/
bin/
lib/
libexec/
share/
[root@localhost local]# cd
arm/4.3.2/bin/
//
安装
在
/usr/local/arm/4.3.2/bin/
的
“bin”
目录下面
[root@localhost bin]#
[root@localhost bin]#
/usr/local/arm/4.3.2/bin/arm-linux-gcc
// arm-linux-
gcc
使用方法
1
:跟上
“
全路径
”
[[root@localhost
bin]#
echo $$PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerber
os/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bi
n:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/
bin
[root@localhost bin]#
export $$PATH
bash: export:
`/usr/lib/qt-3
.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/l
ocal/sbin:/usr/local/bin:/sbin:/b
in:/us
r/sbin:/usr/bin:/usr/X11R6/bin:/root/bin': not a
valid identifier
[root@localhost bin]#
vi /etc/pro
profile
profile.d/ protocols
[root@localhost bin]#
vi
/etc/profile
// arm-linux-gcc
使用方法
2
:添加路径到环境
变量中去
,在系统
的时候就可以
“
任何地方
”
使用
arm-linux-gcc
[root@localhost bin]#
#
Path manipulation
if [
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
pathmunge /usr/local/arm/4.3.2/bin
//
环境变量添加的位置
fi
[root@localhost file]# cat hello.c
#include
int main()
{
char *p=
printf(
//
错误:字符串的输出
printf(
不用加
*p
(字符串指针),
和其他指
针不同
return 0;
}
[root@localhost file]# vi
hello.c
[root@localhost file]#
gcc hello.c -o hello
// x86
编译方式
[root@localhost file]#
./hello
//
在
x86
上能够运行
hello world!!:[root@localhost file]#
arm-linux-gc
arm-linux-gcc
arm-linux-
gcc-4.3.2
arm-linux-gcov
[root@localhost file]#
arm-
linux-gcc hello.c -o hello1
// ARM
编译方式
[root@localhost file]# ls
fork
hello
hello1
hello.c
lib_file
sys_file
time_file
[root@localhost file]#
./hello1
//
在
x86
上不能够运
行
bash: ./hello1:
cannot execute binary file
[root@localhost file]#
2
、
arm-linux-
gcc
交叉编译工具的使用
今晚用了:
arm-linux-objdump -S -D
hello
反汇编指令时,遇到以下提示的错误
:
arm-linux-objdump: Can't disassemble
for architecture UNKNOWN!
现在还不知道是什么错误引起
的
,
等着明天再解决了!!!!!!!
原因是:由于上面用了
“gcc
hello.c
-o hello
x86
编译方式
”
和
“arm
-linux-gcc hello.c -o
hello1
ARM
编译方式
”
产生了
hello
和
hello1
< br>对应不同平台的文件,当然用
“arm
-linux-
objdump -S -
D hello”
用
arm
反汇编指令对
x86
平
台产生的
bin
文件进行反汇编,
肯定出现错误
(
1
)、反汇编
arm-
linux-objdump
使用
[root@localhost file
]arm-
linux-objdump -S -D hello
arm-linux-objdump: Can't disassemble
for architecture UNKNOWN!
[root@localhost file]# ls
fork hello
hello1 hello.c
lib_file
sys_file
time_file
// hello
是
x86
编译出来的,
hello1
是
arm
编译出来的
[root@localhost file]#
arm-
linux-gcc -g hello.c -o hello1
// -g
编译产生带有调试的信息的文
件(反汇编后:
c
语言才能和汇编语言对应上)
[root@localhost file]#
arm-linux-objdump -D -S hello1 >log
-
-
-
-
-
-
-
-
-
上一篇:用友U8数据库表名参照表
下一篇:高三英语_单选纠错练习---时态语态