我想在我的项目中使用优化算法 lbfgs,但我不想自己编写代码。所以我发现Dlib是一个不错的选择。
http://dlib.net/compile.html是一个很好的库。我下载了它。我使用 Windows 7 和 Visual Studio 2012。如果我创建一个新的 Win 32 控制台项目并设置property->configuration properties->VC++ Directories->Include Directories为Dlib(dlib-18.10/) 的路径。

它运行良好,这意味着我可以运行示例。
但是当我将它添加到我的项目中时。我发生错误。(error : "vector" is ambiguous)
我想这可能是因为我包含它的方式。
在 的文件上Dlib,它说,
Again, note that 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>. This will ensure that everything builds correctly.
但我不清楚上面是什么意思。我用谷歌搜索the Visual Studio search path (Tools / Options / Projects and Solutions / VC++ Directories).。但在我的项目中,这是不可编辑的。
我只在 dlib 中使用 optimization.h。如果我删除'using namespace dlib;',然后'typedef matrix column_vector;'那么错误是matrix不是模板。如果我继续“使用命名空间 dlib;” 我有错误“向量”不明确`。
#include <dlib/optimization.h>
#include <iostream>
using namespace std;
using namespace dlib;
// ----------------------------------------------------------------------------------------
// In dlib, the general purpose solvers optimize functions that take a column
// vector as input and return a double. So here we make a typedef for a
// variable length column vector of doubles. This is the type we will use to
// represent the input to our objective functions which we will be minimizing.
typedef matrix<double,0,1> column_vector;