Компилятор не может найти файл заголовка в VS Code - PullRequest
0 голосов
/ 27 мая 2020

При попытке скомпилировать программу на C ++ в VS Code возникает ошибка. Задача выполнения: cl.exe / Zi / EHs c / Fe: 'c: \ Users \ Me \ Documents \ cpp \ VRP \ program.exe' 'c: \ Users \ Me \ Documents \ cpp \ VRP \ program. cc '

Я получаю следующую ошибку: program. cc c: \ Users \ Me \ Documents \ cpp \ VRP \ program. cc (1) : фатальная ошибка C1083: Невозможно открыть включаемый файл: 'linear_solver / linear_solver.h': Нет такого файла или каталога Терминальный процесс завершен с кодом выхода: 1.

Первая строка в моей программе. cc файл это: #include "linear_solver/linear_solver.h"

Путь «C: \ Users \ Me \ Documents \ CPP \ or-tools_VisualStudio2019-64bit_v7.6.7691» находится в моих переменных среды. Полный путь к файлу заголовка linear_solver.h: «C: \ Users \ Me \ Documents \ cpp \ or-tools_VisualStudio2019-64bit_v7.6.7691 \ include \ ortools \ linear_solver \». Как мне указать компилятору Microsoft C ++ (MSV C) "cl.exe" найти этот каталог / файл или изменить оператор include для работы в Visual Studio Code?

My c_cpp_properties. json file это:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Users/Me/Documents/cpp/or-tools_VisualStudio2019-64bit_v7.6.7691/include/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.18362.0",            
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64",
            "compilerArgs": []
        }
    ],
    "version": 4
}

Мой запуск. json это:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "cl.exe build active file"
        }
    ]
}

Мои задачи. json это:

{
    "version": "2.0.0",
    "tasks": [
      {
        "type": "shell",
        "label": "cl.exe build active file",
        "command": "cl.exe",
        "args": [
          "/Zi",
          "/EHsc",
          "/Fe:",
          "${fileDirname}\\${fileBasenameNoExtension}.exe",
          "${file}"
        ],
        "problemMatcher": ["$msCompile"],
        "group": {
          "kind": "build",
          "isDefault": true
        }
      }
    ]
  }
...