dlib 使用
dlib 生成各种版本的库 之后(CMake )可参见官网
1.添加库目录
2.添加库文件
3.把dlib/all/source.cpp 添加到我们的项目工程中, 并且设置[不使用预编译头] 如图
那些开关宏,最好放在工程中
【配置属性】->【C/C++】->【预处理器】 【预处理器定义】这里添加
编译时,头文件载入问题看这2个文件
dlib_basic_cpp_build_tutorial.txt
#error "Don't write #include <dlib/all/source.cpp> in your code." /* In C++, it is generally an error to #include .cpp files. This is because it can lead to what are called multiply defined symbol errors. Therefore, you should compile dlib/all/source.cpp into your application just like you would compile any other .cpp file. If you are using Visual Studio you add .cpp files to your application using the solution explorer window. Specifically, right click on Source Files, then select Add -> Existing Item and select the .cpp files you want to add. For general information on compiling dlib see http://dlib.net/compile.html */
dlib_include_path_tutorial.txt
#error "Don't put the dlib folder in your include path" /* You are getting this error because you have added the dlib folder to your compiler's include search path. You should *NOT* add the dlib folder itself to your compiler's include path. Doing so will cause the build to fail because of name collisions (such as dlib/string.h and string.h from the standard library). Instead you should add the folder that contains the dlib folder to your include search path and then use include statements of the form #include <dlib/queue.h> or #include "dlib/queue.h". This will ensure that everything builds correctly. XCode: The XCode IDE often puts all folders that it knows about into the compiler search path. So if you are using XCode then either don't drag the whole dlib folder into the project or alternatively modify your XCode project settings to not auto-add all folders to the include path. Instead just make sure that the dlib folder is itself inside a folder in your include path. */
linux
Compiling on Linux From Command Line
From within the examples folder, you can compile nearly all of the examples with a single command like so:
g++ -std=c++11 -O3 -I.. ../dlib/all/source.cpp -lpthread -lX11 example_program_name.cpp
On non-Linux systems like Solaris, you might have to link to other libraries. For example, I have seen systems where it was also necessary to supply -lnsl or -lsocket options to g++. Additionally, the X11 development library isn't installed on Ubuntu by default. So if you require it and are using Ubuntu you can install it by typing:
sudo apt-get install libx11-dev
分类:
Deep Learning
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)