【问题标题】:Need help executing binary file on bash terminal with -wall -pedantic -ansi flags需要帮助使用 -wall -pedantic -ansi 标志在 bash 终端上执行二进制文件
【发布时间】:2019-10-09 14:25:16
【问题描述】:

无法在带有 -Wall -pedantic -ansi 标志的 Windows 上的 Visual Studio Code 终端上执行程序。现在的赋值程序只是一个简单的 C 语言“Hello World”主程序,带有一个结构

我尝试在不同的文件夹上使用标志,它们在 VS Code 上运行良好,但在我想要的文件路径上却不行。

gcc -Wall -pednatic -ansi -o q1 -c Question1.c

是我在 .../Assignment_1$ 文件夹中的 Visual Studio Code 终端上所做的

-bash: ./q1: cannot execute binary file: Exec format error

是我做./q1时所说的

【问题讨论】:

  • 您很可能会遇到路径问题。您应该提供更多信息以生成答案
  • -ansi 标志现在已经过时了。
  • @Someprogrammerdude:ANSI C 方言可能已经过时,但编译器开关还没有。

标签: c bash terminal visual-studio-code windows-10


【解决方案1】:

-c 选项告诉 GCC 生成一个 object 文件,而不是可执行文件。不要使用-c 选项来生成可执行(程序)文件。

【讨论】:

  • 好收获!我什至没有看到-c
猜你喜欢
  • 1970-01-01
  • 2018-04-30
  • 1970-01-01
  • 2011-04-03
  • 1970-01-01
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
  • 2016-03-06
相关资源
最近更新 更多