无法从vcpkg安装中包含

huangapple go评论63阅读模式
英文:

Cannot #include <fmt> from vcpkg installation

问题

没有问题,这是您要翻译的内容:

<!-- ⚠ Please use the generated issue template instead to report a port build failure. ⚠ -->
<!-- ⁉ You can find its location at the end of the console output. ⁉ -->

## 主机环境

- 操作系统: [使用WSL的Windows 11(Ubuntu-22.04)]
- 编译器: Clang 14.0.0

## 问题描述

首先,我执行了`vcpkg install fmt --triplet x64-Linux`,一切正常。然后,我在顶层的CMakeLists.txt文件中编写了一些配置,以便找到FMT包。然后,我将FMT链接到我的可执行文件,并成功构建。然而,当我包含fmt时,立即出现错误。

**顶层CMakeLists.txt**
![1](https://user-images.githubusercontent.com/51810664/216830121-709f4aab-36f0-4b0f-9d1e-f6312cc59986.png)

**`app`子目录中的CMakeLists.txt**
![2](https://user-images.githubusercontent.com/51810664/216830067-9062473e-1498-4723-b495-71307de03ad0.png)

**Main.cpp,将生成的可执行文件; 还显示了包含FMT的错误**
![3](https://user-images.githubusercontent.com/51810664/216830070-41c74f71-35c3-4981-a8fb-5f6e346fb522.png)

**甚至IDE成功建议了FMT,表明它知道它的存在**
![4](https://user-images.githubusercontent.com/51810664/216830071-e571c95c-a12c-4250-a502-30baf5bfa15c.png)

**包已经安装的更多证据**
![5](https://user-images.githubusercontent.com/51810664/216830072-2bc74663-da49-4268-be2a-f684f1320dbb.png)

## 如果您想检查的zip文件
[hp_bot.zip](https://github.com/microsoft/vcpkg/files/10611495/hp_bot.zip)

我尝试在c_cpp_properties.json文件中修改我的包含目录,但没有成功。

请告诉我如果还有其他需要帮助的地方。

英文:

<!-- ⚠ Please use the generated issue template instead to report a port build failure. ⚠ -->
<!-- ⁉ You can find its location at the end of the console output. ⁉ -->

Host Environment

  • OS: [Windows 11 using WSL (Ubuntu-22.04)]
  • Compiler: Clang 14.0.0

The issue

Firstly, I did vcpkg install fmt --triplet x64-Linux and everything worked properly. After that, I wrote some configurations in the top-level CMakeLists.txt to find the FMT package. Then, I linked FMT to my executable, and it was built successfully. However, when I include fmt, an error immediately occured.

Top-level CMakeLists.txt
无法从vcpkg安装中包含<fmt>。

CMakeLists.txt in the app subdirectory
无法从vcpkg安装中包含<fmt>。

Main.cpp, the executable that will be generated from; it also shows the error of including FMT
无法从vcpkg安装中包含<fmt>。

Even the IDE managed to suggest FMT, meaning that it knows it exists
无法从vcpkg安装中包含<fmt>。

Further evidence of the package already installed
无法从vcpkg安装中包含<fmt>。

The zip file if you want to inspect

hp_bot.zip

I tried to modify my include directories in the c_cpp_properties.json but found no luck.

答案1

得分: 2

你的vcpkg安装或CMake文件没有问题。你只是包含了错误的头文件。

应该使用以下之一而不是:

#include <fmt/core.h>
英文:

There is nothing wrong with your vcpkg installation or CMake file. You are just including the wrong headers.

Instead of

#include &lt;fmt&gt;

(which is a directory)
you should include some of the files within that directory:

#include &lt;fmt/core.h&gt;

huangapple
  • 本文由 发表于 2023年2月6日 17:01:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75359213.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定