为C++程序创建makefile以使用g ++运行

use*_*229 3 c++ makefile g++ gild

我在一个名为"helloworld.cpp"的文件中有一个示例程序:

#include <iostream>

using namespace std;
int main(int argc, char** argv)
{  
  cout<<"Hello World!";
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试为此编写一个makefile,如下所示:

all:g ++ helloworld.cpp -o helloworld

现在我在Windows上,无法测试这个.但是,当我将其提交给其中一个网站(www.gild.com)时,它告诉我由于构建错误导致提交失败.有人能指出这里有什么问题吗?

Dan*_*ons 5

您可以在依赖项所在的行的一部分上运行该操作.试试这个:

all: 
        g++ helloworld.cpp -o helloworld
Run Code Online (Sandbox Code Playgroud)

确保这是一个标签,而不是任何数量的空格.