Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97327

using VS code C++ tasks.json to compile cpp file in Windows

$
0
0

os system: win10 I just followed the steps in vscode tutorial and after I add a tasks.json for cpp file and the g++ compile failed because the file cannot found in dir. I believe it's because of the the System directory separator. I got the whole output is:

Executing task: 'C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\cpp.exe' -g c:\Users\Snow\Workplace\c_program\hello\hello.cpp -o c:\Users\Snow\Workplace\c_program\hello\hello.exe <
cpp.exe: error: c:UsersSnowWorkplacec_programhellohello.cpp: No such file or directory
cpp.exe: fatal error: no input files
compilation terminated.
The terminal process terminated with exit code: 1

how can I fix it?

my tasks.json file is directly generate by the vscode:

{

        // See https://go.microsoft.com/fwlink/?LinkId=733558 
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "type": "bash",
                "label": "g++.exe build active file",
                "command": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
                "args": [
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}\\${fileBasenameNoExtension}.exe"
                ],
                "options": {
                    "cwd": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin"
                },
                "problemMatcher": [
                    "$gcc"
                ],
                "group": "build"
            }
        ]
    }

Viewing all articles
Browse latest Browse all 97327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>