GCC编译的二进制文件给予"不能执行二进制文件" [英] gcc compiled binaries give "cannot execute binary file"
问题描述
我编译这个程序:
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
使用这个命令:
gcc -c "hello.c" -o hello
当我尝试执行你好,我得到
And when I try to execute hello, I get
bash: ./hello: Permission denied
由于权限
-rw-r--r-- 1 nathan nathan 856 2010-09-17 23:49 hello
由于某些原因?
For some reason??
但无论...更改权限,并试图再次执行后,我得到
But whatever... after changing the permissions and trying to execute again, I get
bash: ./hello: cannot execute binary file
我用gcc(Ubuntu的4.4.3-4ubuntu5)4.4.3
I'm using gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
我在做什么错在这里?它得是显而易见的......它只是为时已晚,我用我的疲惫的眼睛,试图找出这个简单的问题,以保持....
What am I doing wrong here? It's gotta be obvious... it's just too late for me to keep using my tired eyes to try and figure out this simple problem....
P.S。我(有时)上的程序比你好世界更复杂的工作,但是GCC是全线做这个...
P.S. I do (sometimes) work on programs more sophisticated than Hello World, but gcc is doing this across the board...
推荐答案
取 -c
出来。这是制造对象文件,而非可执行文件。
Take the -c
out. That's for making object files, not executables.
这篇关于GCC编译的二进制文件给予&QUOT;不能执行二进制文件&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!