gpt4 book ai didi

linux - gcc 编译的二进制文件给出 "cannot execute binary file"

转载 作者:IT王子 更新时间:2023-10-29 00:21:28 26 4
gpt4 key购买 nike

我编译这个程序:

#include <stdio.h>

int main()
{
printf("Hello World!");
return 0;
}

使用这个命令:

  gcc -c "hello.c" -o hello

当我尝试执行 hello 时,我得到了

bash: ./hello: Permission denied

因为权限是

-rw-r--r-- 1 nathan nathan   856 2010-09-17 23:49 hello

出于某种原因??

但是无论如何......在更改权限并尝试再次执行之后,我得到了

bash: ./hello: cannot execute binary file

我正在使用 gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

我在这里做错了什么?这一定是显而易见的……对我来说已经太晚了,无法继续用我疲惫的眼睛来尝试解决这个简单的问题……

附言我确实(有时)从事比 Hello World 更复杂的程序,但 gcc 正在全面开展这项工作......

最佳答案

取出-c。那是为了制作目标文件,而不是可执行文件。

关于linux - gcc 编译的二进制文件给出 "cannot execute binary file",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3740322/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com