Visual Studio 2010中dlib库的用法 [英] Usage of dlib library in Visual Studio 2010
问题描述
我想在我的小论文项目中使用 dlib 寻求帮助.具体来说,我需要使用BOBYQA优化例程.
I would like to ask for help in using dlib for my little thesis project. Specifically, I need to use the BOBYQA optimisation routine.
我正在用C语言在MS Visual Studio 2010 Express中编写项目.我在使用dlib之类的库时经验为零,我不知道什么是makefile以及如何编写一个makefile.
我在此处找到了一些提示,但是由于我对此事缺乏经验,我只是不知道如何在我的代码中编译和使用dlib.
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.
我想问一个逐步说明,如何将dlib合并到我的代码中,即:
I would like to ask for a step by step instruction how to incorporate dlib into my code, i.e.:
- 我应该在哪里从我也非常感谢一个简单的用法示例代码(我要优化的函数有6个参数).
I would also be very grateful for a simple example code of usage (my function to be optimised has 6 parameters).
推荐答案
如果您使用的是Visual Studio,则不必使用makefile.您可以像平常一样创建项目.然后,要使用dlib,您要做的就是将dlib/all/source.cpp添加到项目中,并将包含dlib文件夹的文件夹添加到包含搜索路径中.如果仅使用BOBYQA,则甚至不必添加dlib/all/source.cpp.
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.
如果这是您第一次使用Visual Studio,而您却迷上了如何创建项目的方法,那么我建议您使用 CMake .它非常易于使用,它将自动为您设置合适的Visual Studio项目.此外,还有一个dlib examples/optimization_ex.cpp 附带的示例应用程序,其中显示了如何调用可以使用cmake使用以下命令来构建BOBYQA和此示例:
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 ..
然后,您应该在build文件夹内找到一个Visual Studio项目,所有设置都已准备就绪,可以开始使用了.将设置它来构建所有dlib示例.如果您在示例文件夹中编辑CMakeLists.txt文件,则可以删除您不感兴趣的示例.
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.
这篇关于Visual Studio 2010中dlib库的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!