我想在 Visual Studio 2013 中使用 Dlib(C++ 库)的图像处理包。
我创建了一个空项目,并在解决方案资源管理器中将“dlib-18.16\dlib\all\source.cpp”添加到我的源文件中。然后,我将 dlib-18.16 的路径添加到我在 VC++ 目录中的包含目录,我还将 dlib-18.16\dlib 的路径添加到我在 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 <image_processing/frontal_face_detector.h>
.
让我举一个假设的例子来更好地解释。您下载了 dlib-18.16.tar.bz2
并将其提取到c:\projects
.这将创建一个名为 c:\projects\dlib-18.16
的文件夹.在您添加的 VC++ 目录中 c:\projects\dlib-18.16
到包含目录。
但是这是不正确的,您应该删除该目录并添加 c:\projects\dlib-18.16\dlib
因为这是项目的包含目录。
这将导致 #include <type_safe_union/type_safe_union_kernel.h>
加载C:\projects\dlib-18.16\dlib\type_safe_union\type_safe_union_kernel.h
以及文件之间的类似内部链接。
关于c++ - Dlib 错误 : error C1083: Cannot open include file :'type_safe_union/type_safe_union_kernel.h' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32016061/