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
posted @ 2018-07-13 01:52  scott_h  阅读(42)  评论(0编辑  收藏  举报