VisualStudioCodeを開発環境で利用しようと思い、試しにC++でデバッグを試したのですが、ビルドしかできずに実行ができずにデバッグできません。
F5でデバッグを実行すると実行ファイルは問題なく生成されますが、
デバッグが始まらず、DEBUG CONSOLEに
Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object.
と表示されます。
C++
1//main.cpp 2#include <iostream> 3#include <string> 4using namespace std; 5 6int main() 7{ 8 string str; 9 cin >> str; 10 cout << str << endl; 11 return 0; 12}
json
1// c_cpp_properties.json 2{ 3 "configurations": [ 4 { 5 "name": "Win32", 6 "includePath": [ 7 "${workspaceFolder}/**", 8 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++", 9 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32", 10 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward", 11 "C:/MinGW/lib/gcc/mingw32/6.3.0/include", 12 "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed", 13 "C:/MinGW/include" 14 ], 15 "defines": [ 16 "_DEBUG", 17 "_UNICODE" 18 ], 19 "browse": { 20 "path": [ 21 "${workspaceFolder}/**", 22 "C:/MinGW/lib/gcc/mingw32/6.3.0/include" 23 ] 24 }, 25 "cStandard": "c11", 26 "cppStandard": "c++17", 27 "intelliSenseMode": "clang-x64" 28 } 29 ], 30 "version": 4 31}
json
1// launch.json 2{ 3 // Use IntelliSense to learn about possible attributes. 4 // Hover to view descriptions of existing attributes. 5 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 6 "version": "0.2.0", 7 "configurations": [ 8 { 9 "name": "run", 10 "type": "cppdbg", 11 "request": "launch", 12 "program": "${workspaceFolder}/a.exe", 13 "args": [], 14 "stopAtEntry": false, 15 "cwd": "${workspaceFolder}", 16 "environment": [], 17 "externalConsole": true, 18 "MIMode": "gdb", 19 "miDebuggerPath": "C:/MinGW/bin/gdb.exe", 20 "setupCommands": [ 21 { 22 "description": "Enable pretty-printing for gdb", 23 "text": "-enable-pretty-printing", 24 "ignoreFailures": true 25 } 26 ], 27 "preLaunchTask": "build / run file" 28 }, 29 { 30 "name": "debug", 31 "type": "cppdbg", 32 "request": "launch", 33 "program": "${workspaceFolder}/a.exe", 34 "args": [], 35 "stopAtEntry": false, 36 "cwd": "${workspaceFolder}", 37 "environment": [], 38 "externalConsole": true, 39 "MIMode": "gdb", 40 "miDebuggerPath": "C:/MinGW/bin/gdb.exe", 41 "setupCommands": [ 42 { 43 "description": "Enable pretty-printing for gdb", 44 "text": "-enable-pretty-printing", 45 "ignoreFailures": true 46 } 47 ], 48 "preLaunchTask": "build / debug file" 49 } 50 ] 51}
json
1//tasks.json 2{ 3 // See https://go.microsoft.com/fwlink/?LinkId=733558 4 // for the documentation about the tasks.json format 5 "version": "2.0.0", 6 "tasks": [ 7 { 8 "label": "build / debug file", 9 "type": "shell", 10 "command": "clang++", 11 "args": [ 12 "--target=i686-pc-windows-gnu", 13 "-std=c++17", 14 "-Wall", 15 "-g", 16 "${file}" 17 ], 18 "group": { 19 "kind": "build", 20 "isDefault": true 21 }, 22 "problemMatcher": [] 23 }, 24 { 25 "label": "build / run file", 26 "type": "shell", 27 "command": "clang++", 28 "args": [ 29 "--target=i686-pc-windows-gnu", 30 "-std=c++17", 31 "-Wall", 32 "${file}" 33 ], 34 "group": { 35 "kind": "build", 36 "isDefault": true 37 }, 38 "problemMatcher": [] 39 } 40 ] 41}
様々なコミュニティや掲示板で確認しましたが、解決法が見つからなかったので、解決策を教えてもらえると助かります。
補足
PC: Windows10
Visual Studio Code: 1.30.0(user setup)
gcc -v:
Using built-in specs. COLLECT_GCC=C:\MinGW\bin\gcc.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls Thread model: win32 gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
clang -v:
clang version 7.0.0 (tags/RELEASE_700/final) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin