C++ Visual Studio代码WSL can';t在/mnt/c/OneDrive中编译文件
我通常将所有编程文件存储在一个驱动器中,这样我就可以随时随地访问它们。但是现在我需要能够在Linux机器上编译我的C++程序。因此,我尝试在WSL模式下使用visual studio代码,但当我尝试编译和调试代码时,我被告知在指定位置找不到任何*.cpp文件,但文件显然在那里。如果我自己在ubuntu窗口中运行compile命令,它就可以正常工作。当我将文件从/mnt移动到我的主目录时,一切正常。为什么我的compile命令在我从ubuntu窗口使用时工作得很好,而现在在VS代码尝试使用时却工作得很好?有什么想法吗 这是我的task.json文件和launch.json文件:C++ Visual Studio代码WSL can';t在/mnt/c/OneDrive中编译文件,c++,visual-studio-code,gdb,g++,windows-subsystem-for-linux,C++,Visual Studio Code,Gdb,G++,Windows Subsystem For Linux,我通常将所有编程文件存储在一个驱动器中,这样我就可以随时随地访问它们。但是现在我需要能够在Linux机器上编译我的C++程序。因此,我尝试在WSL模式下使用visual studio代码,但当我尝试编译和调试代码时,我被告知在指定位置找不到任何*.cpp文件,但文件显然在那里。如果我自己在ubuntu窗口中运行compile命令,它就可以正常工作。当我将文件从/mnt移动到我的主目录时,一切正常。为什么我的compile命令在我从ubuntu窗口使用时工作得很好,而现在在VS代码尝试使用时却工作
task.json
{
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${cwd}/*.cpp",
"-o",
"${cwd}/main"
],
"options": {
"cwd": "/usr/bin"
}
}
],
"version": "2.0.0"
}
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${cwd}/main",
"args": ["test1.txt"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
launch.json
{
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${cwd}/*.cpp",
"-o",
"${cwd}/main"
],
"options": {
"cwd": "/usr/bin"
}
}
],
"version": "2.0.0"
}
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${cwd}/main",
"args": ["test1.txt"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
即使没有WSL,使用OneDrive存储源代码也是有问题的。在Visual Studio中,如果您的代码位于OneDrive中,则为Windows应用商店生成程序包将失败。在IntelliJ中,也会出现许多问题。GitHub现在有免费的私有存储库,还有许多其他选项可以避免在源代码中使用OneDrive。即使没有WSL,使用OneDrive存储源代码也是有问题的。在Visual Studio中,如果您的代码位于OneDrive中,则为Windows应用商店生成程序包将失败。在IntelliJ中,也会出现许多问题。GitHub现在免费提供私有存储库,还有许多其他选项可以避免在源代码中使用OneDrive