質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
デバッグ

デバッグはプログラムのバグや欠陥を検知し、開発中のバグを取り除く為のプロセスを指します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

解決済

2回答

1691閲覧

VSCodeでC++のサンプルプログラムを実行できません。

sumachu

総合スコア22

デバッグ

デバッグはプログラムのバグや欠陥を検知し、開発中のバグを取り除く為のプロセスを指します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2020/01/23 15:22

Using Mingw-w64 in VS Codeの手順に従い、下記のサンプルプログラムを実行してみましたが、エラーメッセージが表示されます。

サンプルプログラム

C++

1#include <iostream> 2#include <vector> 3#include <string> 4 5using namespace std; 6 7int main() 8{ 9 vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"}; 10 11 for (const string &word : msg) 12 { 13 cout << word << " "; 14 } 15 cout << endl; 16}

launch.json

json

1{ 2 // IntelliSense を使用して利用可能な属性を学べます。 3 // 既存の属性の説明をホバーして表示します。 4 // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 5 "version": "0.2.0", 6 "configurations": [ 7 { 8 "name": "g++.exe build and debug active file", 9 "type": "cppdbg", 10 "request": "launch", 11 "program": "${fileDirname}\${fileBasenameNoExtension}.exe", 12 "args": [], 13 "stopAtEntry": false, 14 "cwd": "${workspaceFolder}", 15 "environment": [], 16 "externalConsole": false, 17 "MIMode": "gdb", 18 "miDebuggerPath": "C:\mingw-w64\mingw32\bin\gdb.exe", 19 "setupCommands": [ 20 { 21 "description": "gdb の再フォーマットを有効にする", 22 "text": "-enable-pretty-printing", 23 "ignoreFailures": true 24 } 25 ], 26 "preLaunchTask": "g++.exe build active file" 27 } 28 ] 29}

tasks.json

JSON

1{ 2 "version": "2.0.0", 3 "tasks": [ 4 { 5 "type": "shell", 6 "label": "g++.exe build active file", 7 "command": "C:\mingw-w64\mingw32\bin\g++.exe", 8 "args": [ 9 "-g", 10 "${file}", 11 "-o", 12 "${fileDirname}\${fileBasenameNoExtension}.exe" 13 ], 14 "options": { 15 "cwd": "C:\mingw-w64\mingw32\bin" 16 }, 17 "problemMatcher": [ 18 "$gcc" 19 ], 20 "group": { 21 "kind": "build", 22 "isDefault": true 23 } 24 } 25 ] 26}

エラーメッセージは下記の通りです。

=thread-group-added,id="i1" GNU gdb (GDB) 8.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Warning: Debuggee TargetArchitecture not detected, assuming x86_64. =cmd-param-changed,param="pagination",value="off" [New Thread 1132.0x39a8] [New Thread 1132.0xd00] [New Thread 1132.0x320c] [New Thread 1132.0x40cc] [Thread 1132.0x40cc exited with code 3221225785] [Thread 1132.0x320c exited with code 3221225785] The program 'c:\Users\user\C++works\VSCode_cpp\cpp_AtCoder.exe' has exited with code 0 (0x00000000). ERROR: Unable to start debugging. GDB exited unexpectedly. ERROR: During startup program exited with code 0xc0000139.

このエラーを解消するにはどうすればいいでしょうか。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

MinGWをインストールする際に、32bit版をインストールしていましたが、64bit版に変更したところ、エラーメッセージなく、サンプルプログラムを実行できました。

投稿2020/01/24 00:25

sumachu

総合スコア22

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

このエラーを解消するにはどうすればいいでしょうか。

C++に精通しているわけではありませんがまずはエラーを読むことです。

エラーメッセージの読み方と対処, 検索や質問の原則

エラーが何を言っているのか知らないと調べようがないですし、対策も決まりません。
※もしエラーについて調べたことがあればそれもきちんと記載しないと伝わりません

投稿2020/01/23 20:52

編集2020/01/23 20:53
m.ts10806

総合スコア80850

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問