【问题标题】:I am having trouble understanding a compiling error /bin/sh: 1: ./a.out: not found with hello world script我无法理解编译错误 /bin/sh: 1: ./a.out: not found with hello world script
【发布时间】:2015-12-16 04:55:32
【问题描述】:

当我使用众所周知的 hello world 脚本时。我终于把所有东西都准备好了并修复了所有错误但是当我编译这个新错误时弹出告诉我这个 /bin/sh: 1: ./a.out: not found.

对于 hello.ccp 文件,我的脚本如下所示:

#include <iostream>

int main()
 {
  std::cout << "Hello World!\n";
  return 0;
 }

而我的 makefile 看起来像这样:

hello.ccp:
    g++ -std=gnu++11    hello.cpp

有什么想法吗?非常感谢!

【问题讨论】:

  • 我猜你的 makefile 不止于此。您如何尝试运行该程序?
  • 谢谢,我修复了 makefile 的问题,但有一个新错误:makefile:1: *** target pattern contains no '%'。停止。

标签: c++ compilation makefile g++


【解决方案1】:

了解manualtargeta.out,因为这就是您想要创建 的目标。所以将hello.ccp 更改为a.out。由于hello.cppa.out先决条件,Makefile 需要如下所示:

a.out: hello.cpp
    g++ -std=gnu++11 hello.cpp

另外,请确保您使用制表符而不是空格来缩进配方。 Makefile 需要标签。

【讨论】:

  • 我修复了这两个问题,但仍然显示错误
  • @Gsachs 我的答案现在应该已经完全解决了。什么错误?
  • 谢谢,我把它改成了原来的样子,但现在它说:makefile:1: *** target pattern contains no '%'。停止。 @user5684998 它修复了原来的错误,所以谢谢!
  • 如果我们看到实际的makefile会更容易。
  • @Gsachs 它让你在你的static patterns 之一中有错字。
猜你喜欢
  • 1970-01-01
  • 2018-06-06
  • 2019-09-11
  • 1970-01-01
  • 2015-12-18
  • 2020-07-28
  • 1970-01-01
  • 2020-01-28
  • 2020-09-26
相关资源
最近更新 更多