首页 > 解决方案 > 如何在 macOS VS Code 上正确配置 vcpkg C++ includePath?

问题描述

我用 Homebrew 安装了 vcpkg。我按照官方 vcpkg 文档的说明进行操作。

我使用了这个命令:

vcpkg integrate project

并收到以下消息:

Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/vcpkg/2020.11-1/libexec/scripts/buildsystems/vcpkg.cmake"

我添加到 VS Code settings.json

"cmake.configureSettings": {
    "CMAKE_TOOLCHAIN_FILE": "/usr/local/Cellar/vcpkg/2020.11-1/libexec/scripts/buildsystems/vcpkg.cmake"
  }

和 c_cpp_properties.json includePath:

"/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages/**"

或者:

"/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages"

并且 VS Code 仍然找不到任何 vcpkg 库。我有错误:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/emilmordarski/Uczelnia/PG/teams/freeglut3.cpp).C/C++(1696)
cannot open source file "freeglut/include/GL/glut.h"C/C++(1696)

我使用的是 macOS Big Sur 11.1。我已经安装了 C/C++、Cmake 和其他一些扩展来支持 VS Code 中的 C++。

我也试过 install vcpkg cloning git repo,但效果是一样的。有任何想法吗?

标签: c++macosvisual-studio-codepathvcpkg

解决方案


推荐阅读