为c++程序创建makefile,以便与c++一起运行

Creating makefile for a C++ program to run with g++

本文关键字:c++ 运行 一起 程序 创建 makefile      更新时间:2023-10-16

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

#include <iostream>
using namespace std;
int main(int argc, char** argv)
{  
  cout<<"Hello World!";
  return 0;
}

我想写一个makefile,如下所示:

all: g++ helloworld.cpp -o helloworld

现在我在windows上,无法测试这个。然而,当我提交到一个网站(www.gild.com),它告诉我,由于构建错误,提交已经失败。有人能指出这里有什么问题吗?

要在依赖项所在的行上运行操作。试试这个:

all: 
        g++ helloworld.cpp -o helloworld

确保是一个制表符,而不是任意数量的空格

如果您的解决方案只包含一个类,则不需要makefile

http://www.gild.com/challenges/details/code_submission_guidelines?keyword=missile

编辑:此外,您还需要确保您的文件夹组织正确。这是一个很好的开始http://community.gild.com/gild/topics/help_me_to_submit_helloworld_solution_in_java