【问题标题】:VSCode not using Vcpkg acquired librariesVSCode 不使用 Vcpkg 获取的库
【发布时间】:2018-08-04 09:43:26
【问题描述】:

由于某种原因,VSCode 无法看到 Vcpkg 安装的库目录中的标头。我在 Ubuntu 17.04 上使用 CMake 构建系统。 我收到如下错误:

[GCC] GL/glew.h: No such file or directory

我的 CMakeLists.txt 看起来像这样:

cmake_minimum_required (VERSION 3.8)
set (CMAKE_CXX_STANDARD 17)

project ("RubeusCore")

FIND_PACKAGE(OpenGL REQUIRED)

# Include sub-projects.
add_subdirectory ("RubeusCore")

RubeusCore/CMakeLists.txt 是这样的:

cmake_minimum_required (VERSION 3.8)

link_directories(Source/)

file(GLOB_RECURSE SOURCES
    Source/*.cpp
)

# Add source to this project's executable.
add_executable (RubeusCore "RubeusCore.cpp" "RubeusCore.h" ${SOURCES})

target_include_directories(RubeusCore PUBLIC ./Include)
include_directories(${OPENGL_INCLUDE_DIRS})

target_link_libraries(RubeusCore ${OPENGL_LIBRARIES})

.vscode/c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${vcpkgRoot}/x64-linux/include/"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

另外,我已经在 CMake 中指定了一次 Vcpkg 工具链文件。

【问题讨论】:

  • 试试"${vcpkgRoot}/installed/x64-linux/include/"

标签: cmake visual-studio-code vcpkg


【解决方案1】:

您可以尝试在 VSCODE settings.json 中添加 VCPKG Toolchain 文件

...

"cmake.configureSettings": {
        "CMAKE_TOOLCHAIN_FILE": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
}


【讨论】:

    猜你喜欢
    • 2021-05-27
    • 2019-08-25
    • 2022-01-22
    • 2023-02-02
    • 1970-01-01
    • 2023-01-12
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    相关资源
    最近更新 更多