2024年版 WindowsでのVSCode+Dev-C++およびPython環境構築ガイド

VSCodeインストール手順

公式サイトVisual Studio Codeから最新版をダウンロードします。インストール後、日本語化するために「拡張機能」メニューから「Japanese Language Pack」を検索してインストールします。適用後、再起動でUIが日本語表示になります。

C++開発環境(Dev-C++)構築

公式ソースOrwell Dev-C++からコンパイラをダウンロードします。インストール時はCドライブ以外のパス(例:D:\DevCpp)を指定してください。

環境変数PATHに以下のパスを追加: D:\DevCpp\MinGW64\bin

VSCode拡張機能として「C/C++」と「C++ Intellisense」をインストールします。

構成ファイル設定

プロジェクトフォルダ内に以下の設定ファイルを作成します(日本語パス禁止):

launch.json(デバッグ構成)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "GDBデバッグ",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\DevCpp\\MinGW64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "pretty printing有効化",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gccコンパイル"
        }
    ]
}

tasks.json(ビルドタスク)

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "gccコンパイル",
            "type": "shell",
            "command": "D:\\DevCpp\\MinGW64\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\DevCpp\\MinGW64\\bin"
            },
            "problemMatcher": ["$gcc"],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

c_cpp_properties.json(インテリセンス設定)

{
    "configurations": [
        {
            "name": "MinGW構成",
            "includePath": [
                "${workspaceFolder}/**",
                "D:\\DevCpp\\MinGW64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include\\c++",
                "D:\\DevCpp\\MinGW64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include\\c++\\x86_64-w64-mingw32"
            ],
            "defines": ["_DEBUG", "UNICODE"],
            "compilerPath": "D:\\DevCpp\\MinGW64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

Python開発環境構築

最新バージョン(3.12.3)は公式ダウンロードページからインストールします。VSCode拡張機能として「Python」および「Jupyter」をインストールします。

デバッグ実行手順:

  1. Pythonファイルを開く
  2. F5キー押下
  3. デバッガー選択:「Python Debugger」
  4. 実行構成が自動生成されます

不足しているライブラリはターミナルでインストール: pip install numpy pandas

タグ: Visual Studio Code C++開発 Pythonプログラミング Windows開発環境 MinGW

7月19日 18:35 投稿