ubuntu下编译个hello.c 执行时总是提醒无法执行二进制文件
发表于 : 2011-08-20 21:59
在vmware里面新装了个ubuntu11.04;
创建了个hello.c文件;
gcc -o hello -c hello.c;
./hello
提示 bash: ./hello: 无法执行二进制文件
chmod a+x hello 已经执行过了。 不知道有没有遇到过类似问题的朋友。
过程可参考这里:
root@snow-virtual-machine:/mySource# ll
总用量 12
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# cat hello.c
#include <stdio.h>
int main()
{
printf("hello world!\n");
return 0;
}
root@snow-virtual-machine:/mySource# gcc -o hello -c hello.c
root@snow-virtual-machine:/mySource# ll
总用量 16
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rw-r--r-- 1 root root 856 2011-08-20 22:04 hello
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# chmod a+x hello
root@snow-virtual-machine:/mySource# ll
总用量 16
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rwxr-xr-x 1 root root 856 2011-08-20 22:04 hello*
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# ./hello
bash: ./hello: 无法执行二进制文件
root@snow-virtual-machine:/mySource# sudo ./hello
./hello: 1: Syntax error: word unexpected (expecting ")")
创建了个hello.c文件;
gcc -o hello -c hello.c;
./hello
提示 bash: ./hello: 无法执行二进制文件
chmod a+x hello 已经执行过了。 不知道有没有遇到过类似问题的朋友。
过程可参考这里:
root@snow-virtual-machine:/mySource# ll
总用量 12
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# cat hello.c
#include <stdio.h>
int main()
{
printf("hello world!\n");
return 0;
}
root@snow-virtual-machine:/mySource# gcc -o hello -c hello.c
root@snow-virtual-machine:/mySource# ll
总用量 16
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rw-r--r-- 1 root root 856 2011-08-20 22:04 hello
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# chmod a+x hello
root@snow-virtual-machine:/mySource# ll
总用量 16
drwxr-xr-x 2 snow snow 4096 2011-08-20 22:04 ./
drwxr-xr-x 23 root root 4096 2011-08-20 20:50 ../
-rwxr-xr-x 1 root root 856 2011-08-20 22:04 hello*
-rw-r--r-- 1 root root 73 2011-08-20 22:03 hello.c
root@snow-virtual-machine:/mySource# ./hello
bash: ./hello: 无法执行二进制文件
root@snow-virtual-machine:/mySource# sudo ./hello
./hello: 1: Syntax error: word unexpected (expecting ")")