C++ 我的C++;项目赢得';在visualstudio代码上编译
我试图首次使用VisualStudio代码,而我的C++将无法编译。 我已经从MSYS2将mingw的bin和bash.exe添加到我的路径中。我所有的代码都在同一个目录中,并且直接来自microsoft的指南(我确实将路径更改为我的)。我的所有文件也在同一个目录中 我已经包括了文件 helloworld.cpp:C++ 我的C++;项目赢得';在visualstudio代码上编译,c++,windows,visual-studio-code,mingw-w64,C++,Windows,Visual Studio Code,Mingw W64,我试图首次使用VisualStudio代码,而我的C++将无法编译。 我已经从MSYS2将mingw的bin和bash.exe添加到我的路径中。我所有的代码都在同一个目录中,并且直接来自microsoft的指南(我确实将路径更改为我的)。我的所有文件也在同一个目录中 我已经包括了文件 helloworld.cpp: #include <iostream> using namespace std; int main() { cout << "Hello Worl
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "C:\\Mingw-w64\\mingw32\\bin\\g++.exe",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Mingw-w64\\mingw32\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
该文件无法生成,我不断收到相同的错误消息:
g++.exe:错误:helloworld.cpp:没有这样的文件或目录g++.exe:
致命错误:未终止任何输入文件编译。终点站
进程终止,退出代码为:1
编译器似乎无法找到源文件,请更新tasks.json以编译具有完整路径的程序
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",//Just
"-o",//edit
"${workspaceFolder}\\${fileBasenameNoExtension}"//these
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
<>这里>代码> ${file } /Cult>给出了具有扩展名(.cp)的文件的完整路径,<代码> ${WorkStudioFase}} /<代码>和
helloworld.cpp
是否在正确的文件夹中?在我看来,g++
似乎无法通过此输出找到您的源文件g++.exe:错误:helloworld.cpp:没有这样的文件或目录欢迎您,如果您觉得这个答案有用,请接受并投票
That eventually worked after I exited the shell and re-opened it
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "g++",
"args": [
"-g", "main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
That eventually worked after I exited the shell and re-opened it
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "g++",
"args": [
"-g", "main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}