JetbrainsのFleetを使ってC++プログラムを実行する方法
JetbrainsのFleetは、VSCodeに対抗して開発されたIDEです。Jetbrainsの他のツールと異なり、プログラム実行にはrun.jsonを作成しなければならず、私のような初心者には設定がやや難解かなと感じています。
そこで今回は、Fleetを使って簡単なC++プログラムを実行する手順を紹介します。
手順
- 下記のC++プログラムを作成します。ファイル名は
hello_world.cpp
とします。 - Fleet画面右上の三角の
Run
ボタンをクリックすると、Edit run configurations
という項目が出るので、それを選択。 - 表示された
run.json
ファイル内に下記項目を入力。 - 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"
}
]
}