Usage of dlib library in Visual Studio 2010
I would like to ask for help in using dlib for my little thesis project. Specifically, I need to use the BOBYQA optimisation routine.
I am writing the project in MS Visual Studio 2010 Express in C language. I have zero experience in using libraries such as dlib and I don't have any idea what a makefile is and how to write one.
I have found a little hint here but due to my lack of experience in the matter, I just can't figure out how to compile and make use of dlib in my code.I would like to ask for a step by step instruction how to incorporate dlib into my code, i.e.:
- 开发者_如何学Python
- where exactly should I extract the dlib folder from the zip file?
- should I add some files to the Visual Studio project?
- are there any other problems I am not yet aware of?
I would also be very grateful for a simple example code of usage (my function to be optimised has 6 parameters).
If you are using visual studio then you don't have to use makefiles. You can create your project just like you normally would. Then to use dlib all you have to do is add dlib/all/source.cpp to your project and add the folder containing the dlib folder into your include search path. If you only use BOBYQA then you don't even have to add dlib/all/source.cpp.
If this is your first time using visual studio and you are getting hung up on how to create the project then I would suggest using CMake. It's very easy to use and it will setup an appropriate visual studio project for you automatically. Moreover, there is an example application which comes with dlib examples/optimization_ex.cpp which shows how to call BOBYQA and this example can be built using cmake with the following commands:
cd examples
mkdir build
cd build
cmake ..
Then you should find a visual studio project inside the build folder all setup and ready to go. It will be setup to build all the dlib examples. If you edit the CMakeLists.txt file in the examples folders you can remove examples you aren't interested in.
I tried two methods (1) and (2) under but it wasn't the intention of Dlib. The method (3) looks like working at this moment.
There is an example in Visual Studio 2013 at How to setup Dlib with Visual Studio 2013 without CMake?.
The difference in 2010 version, you have to use Property -> Configuration Properties -> (1) VC++ Directories or (2) C/C++ -> General
Regarding the source.cpp file, I just added on Source Files.
The method that I successfully applied is (so far)
(3) #include "dlib/image_processing/frontal_face_detector.h"
The dlib folder should be located in current source directory (Where does Visual Studio look for C++ header files? and https://msdn.microsoft.com/en-us/library/36k2cdd4(v=VS.100).aspx for details)
精彩评论