英文:
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
CMakeLists.txt in the app
subdirectory
Main.cpp, the executable that will be generated from; it also shows the error of including FMT
Even the IDE managed to suggest FMT, meaning that it knows it exists
Further evidence of the package already installed
The zip file if you want to inspect
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 <fmt>
(which is a directory)
you should include some of the files within that directory:
#include <fmt/core.h>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论