首页 > 解决方案 > 使用 vcpkg 安装 box2d

问题描述

当我尝试#include <box2d/box2d.h>在 vscode 中时。我收到了这个错误:

fatal error: box2d/box2d.h: No such file or directory
#include <box2d/box2d.h>

甚至当我将它包含在
我的 vcpkg 列表中时,vscode 也会自动完成库,./vcpkg list
box2d:x64-linux 2019-12-31 An open source C++ engine for simulating rigid b...
我也进行了集成步骤./vcpkg integrate install
输出:

Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/mohamed/packman/scripts/buildsystems/vcpkg.cmake"

安装库时我错过了一步吗

标签: c++cmakelibrariesvscode-settingsvcpkg

解决方案


安装软件包时,vcpkg install box2d您应该有 CMake 目标说明。例如我有这个:

The package box2d:x64-linux provides CMake targets:

find_package(unofficial-box2d CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::box2d::box2d)

然后,您需要使用这些说明更新您的CMakeLists.txt,并最终替换main为您的目标名称。


推荐阅读