0

我正在尝试在 VSCode 中使用 mlpack。我已经使用 brew 安装了库,并在 c_cpp_properties.json 中包含了路径:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/opt/homebrew/Cellar/mlpack/3.4.2_2/include"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "macos-clang-arm64"
        }
    ],
    "version": 4
} 

但是,当我尝试包含 core.hpp 时,出现以下错误:

cannot open source file "boost/serialization/serialization.hpp" (dependency of "mlpack/core.hpp")C/C++(1696)

有谁知道如何解决这个问题?我的理解是 brew 处理依赖关系,这是错误的吗?

这是我当前的tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build all files",
            "command": "/usr/bin/clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${workspaceFolder}/src/*.cpp",
                "--include-directory=/opt/homebrew/Cellar/mlpack/3.4.2_2/include",
                "--include-directory=/opt/homebrew/Cellar/boost/1.75.0_3/include",
                "--include-directory=/opt/homebrew/Cellar/armadillo/10.4.1_1/include",
                "-o",
                "${workspaceFolder}/build/app",
                "-larmadillo",
                "-lmlpack"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: /usr/bin/clang++"
        }
    ]
}

编辑:如果我为 boost 和犰狳添加路径:

"includePath": [
                "${workspaceFolder}/**",
                "/opt/homebrew/Cellar/mlpack/3.4.2_2/include",
                "/opt/homebrew/Cellar/boost/1.75.0_3/include",
                "/opt/homebrew/Cellar/armadillo/10.4.1_1/include"
            ],

错误变为:

'mlpack/core.hpp' file not found
4

0 回答 0