.MinGW-w64 ダウンロード
https://github.com/niXman/mingw-builds-binaries/releases
例
バージョン 13.1.0の場合
x86_64-13.1.0-release-win32-seh-msvcrt-rt_v11-rev1.7z
.ファイル構成
.vscode
c_cpp_properties.json
launch.json
tasks.json
main.cpp
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/13_1_0_x86_64_w64", // DXライブラリのパス
"C:/mingw64/include" // MinGW-w64のパス
],
"defines": [
"_DEBUG",
"MBCS",
"_MBCS"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/mingw64/bin/gcc.exe", // MinGW-w64のパス
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "gcc-x86",
"compilerArgs": [
"-DDX_GCC_COMPILE",
"-DDX_NON_INLINE_ASM"
]
}
],
"version": 4
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 起動",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main.exe", // 実行ファイルのパス
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/mingw64/bin/gdb.exe", // MinGW-w64のパス
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}
task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn": [
"compile",
"link"
],
"dependsOrder": "sequence"
},
{
"label": "compile",
"type": "shell",
"command": "g++.exe",
"args": [
"-g",
"-c",
"main.cpp", // ソースコード ファイル名
"-IC:/mingw64/include", // MinGW-w64のパス
"-IC:/13_1_0_x86_64_w64", // DXライブラリのパス
"-I",
".",
"-DDX_GCC_COMPILE",
"-DDX_NON_INLINE_ASM",
],
"problemMatcher": [
"$gcc"
]
},
{
"label": "link",
"type": "shell",
"command": "g++",
"args": [
"main.o",
"-mwindows",
"-LC:/mingw64/lib", // MinGW-w64のパス
"-LC:/13_1_0_x86_64_w64", // DXライブラリのパス
"-lDxLib",
"-lDxUseCLib",
"-lDxDrawFunc",
"-ljpeg",
"-lpng",
"-lzlib",
"-ltiff",
"-ltheora_static",
"-lvorbis_static",
"-lvorbisfile_static",
"-logg_static",
"-lbulletdynamics",
"-lbulletcollision",
"-lbulletmath",
"-lopusfile",
"-lopus",
"-lsilk_common",
"-lcelt",
"-o",
"main.exe" // 実行ファイル名
],
"problemMatcher": [
"$gcc"
]
}
]
}
main.cpp
#include "DxLib.h"
// プログラムは WinMain から始まります
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
if (DxLib_Init() == -1) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
ChangeWindowMode(TRUE);
DrawPixel(320, 200, GetColor(0, 255, 0)); // 点を打つ
DrawPixel(320, 240, GetColor(255, 255, 255)); // 点を打つ
WaitKey(); // キー入力待ち
DxLib_End(); // DXライブラリ使用の終了処理
return 0; // ソフトの終了
}