求助:ubuntu下编译生成的二进制可执行文件不能运行。

内核编译和嵌入式产品的设计与开发
回复
colinyao
帖子: 6
注册时间: 2008-12-02 21:51

求助:ubuntu下编译生成的二进制可执行文件不能运行。

#1

帖子 colinyao » 2008-12-02 22:00

我打开GDB,调试刚刚用gcc编译的test文件,执行(gdb)run时,提示无法执行二进制文件,在shell下直接执行./test也是说无法执行二进制文件,请问这是什么问题啊?
xiaoQ008
帖子: 5
注册时间: 2008-11-23 20:49

Re: 求助:ubuntu下编译生成的二进制可执行文件不能运行。

#2

帖子 xiaoQ008 » 2008-12-02 22:47

if you want to use gdb tool,you should compile your source file with -g option
can you show your source code for us?
colinyao
帖子: 6
注册时间: 2008-12-02 21:51

Re: 求助:ubuntu下编译生成的二进制可执行文件不能运行。

#3

帖子 colinyao » 2008-12-02 23:39

你说的我用gcc编译的时候加了。打开gdb用list显示代码后也能设置断点,但是每次执行run时都不往下走,代码是个很简单的小程序,就是输出C=A/B.会不会我少装什么工具啊。
colinyao
帖子: 6
注册时间: 2008-12-02 21:51

Re: 求助:ubuntu下编译生成的二进制可执行文件不能运行。

#4

帖子 colinyao » 2008-12-03 10:37

以下是终端显示信息:
colinyao@colinyao-desktop:~$ arm-linux-gcc -g test.c -o test
colinyao@colinyao-desktop:~$ gdb
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
(gdb) file test
Reading symbols from /home/colinyao/test...done.
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) list
1 #include <stdio.h>
2 int main()
3 {
4 int a,b,c;
5 a=9;
6 b=3;
7 c=a/b;
8 printf("The result of %d/%d is %d\n",a,b,c);
9 return 0;
10 }
(gdb) run
Starting program: /home/colinyao/test
/bin/bash: /home/colinyao/test:无法执行二进制文件
/bin/bash: /home/colinyao/test: Success

Program exited with code 01.
You can't do that without a process to debug.
(gdb)
谋先
帖子: 12
注册时间: 2008-07-05 11:12

Re: 求助:ubuntu下编译生成的二进制可执行文件不能运行。

#5

帖子 谋先 » 2008-12-05 10:53

你用的是arm-elf-gcc,也就是硬件上是ARM的,但是你在PC上的i386硬件上运行,那是不行的。
回复