LoginSignup
1
0

FleetでC++を実行してみる

Posted at

JetbrainsのFleetを使ってC++プログラムを実行する方法

JetbrainsのFleetは、VSCodeに対抗して開発されたIDEです。Jetbrainsの他のツールと異なり、プログラム実行にはrun.jsonを作成しなければならず、私のような初心者には設定がやや難解かなと感じています。
そこで今回は、Fleetを使って簡単なC++プログラムを実行する手順を紹介します。

手順

  1. 下記のC++プログラムを作成します。ファイル名はhello_world.cppとします。
  2. Fleet画面右上の三角のRunボタンをクリックすると、Edit run configurationsという項目が出るので、それを選択。
  3. 表示されたrun.jsonファイル内に下記項目を入力。
  4. hello_world.cppに戻り、再度Runボタンをクリックして、Build->Runの順に実行。

ファイル

C++ プログラム

// Name : hello_world.cpp

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello world." << endl;
    return 0;
}

run.json

hello_worldの部分を適宜実行するファイル名に変更してください。
"program": "$PROJECT_DIR$/hello_world"の部分にPath doesn't existエラーが表示がされますが、Buildすると解消します。

{
    "configurations": [
        {
            "type": "command",
            "name": "Build",
            "program": "g++",
            "args": [
                "$PROJECT_DIR$/hello_world.cpp",
                "-o",
                "$PROJECT_DIR$/hello_world"
            ]
        },
        {
            "type": "command",
            "name": "Run",
            "program": "$PROJECT_DIR$/hello_world"
        }
    ]
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0