Dlib 错误:错误 C1083:无法打开包含文件:"type_safe_union/type_safe_union_kernel.h"

Dlib Error: error C1083: Cannot open include file:'type_safe_union/type_safe_union_kernel.h'

本文关键字:union type 错误 safe kernel 包含 C1083 Dlib 文件      更新时间:2023-10-16

我想使用Visual Studio 2013中的Dlib (c++库)图像处理包。

我创建了一个空项目,并在解决方案资源管理器的源文件中添加了"dlib-18.16dliball Source .cpp"。然后,我将dlib-18.16的路径添加到我的vc++目录中的包含目录中,我还将dlib-18.16dlib的路径添加到我的Visual Studio C/c++ General中的附加包含目录中。

我可以运行文件matrix_ex.cpp,这是Dlib的一个例子,但我不能运行文件face_detection_ex.cpp,因为错误"无法打开包括文件:'type_safe_union/type_safe_union_kernel.h'",这实际上是由#include <dlib/image_processing/frontal_face_detector.h>

行引起的

如何解决这个问题?为什么程序找到一些头文件,但它不能找到其他的,而他们都位于同一文件夹?

你需要将dlib文件夹本身添加到vc++目录中的Include目录中,而不是添加它上面的文件夹。

通过扩展,这意味着您的include指令需要是#include <image_processing/frontal_face_detector.h>

让我举一个假设的例子来更好地解释。您下载dlib-18.16.tar.bz2并将其解压缩到c:projects。这将创建一个名为c:projectsdlib-18.16的文件夹。在vc++目录中添加c:projectsdlib-18.16到Include目录

然而,这是不正确的,你应该删除该目录,而不是添加c:projectsdlib-18.16dlib,因为这是项目的包含目录。

这将导致#include <type_safe_union/type_safe_union_kernel.h>加载C:projectsdlib-18.16dlibtype_safe_uniontype_safe_union_kernel.h以及文件之间类似的内部链接。