내 프로젝트에서 최적화 알고리즘 lbfgs를 사용하고 싶지만 직접 코딩하고 싶지는 않습니다. 그래서 Dlib
은 좋은 옵션입니다.Visual Studio 2012에서 dlib 사용
http://dlib.net/compile.html은 좋은 라이브러리입니다. 나는 그것을 다운로드했다. 윈도우 7과 비주얼 스튜디오 2012를 사용합니다. 새로운 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.
그러나 나는 위의 의미를 취소하고 있지 않다. 나는 go googled 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;
당신은 모든 헤더는 디렉토리,하지만 한 단계 위로를 가리 키지한다. 그런 다음 헤더를 #include로 포함시킵니다. –
@HalilKaskavalci, 의견을 주셔서 감사합니다. 내가 사용할 헤더가 확실하지 않습니다. 나는 C++에서 벡터를 사용한다. 그리고 언급했듯이, Dlib 자체에는 vector.h 파일이 있습니다. 하지만 C++ std에서'vector'를 사용하기 때문에 #include를 추가해야합니까? –
Vivian
OK 지금 귀하의 문제를 이해합니다. 우선, std에서 무언가를 포함하고 싶을 때마다, #include'을 포함하면됩니다. 도형 아래에있는 dlib의 벡터가 필요하다고 가정 해 봅시다. 그런 다음'#include '를 포함시켜야합니다. 그 (것)들을 사용하고 싶을 때마다, 네임 스페이스를 지정해야한다. 네임 스페이스는 컴파일러에게 혼동을주기 때문이다.프로그램에서 std와 dlib 네임 스페이스를 모두 사용한다면, 사용할 때마다'std :: vector' 또는'dlib :: vector'라고 말해야합니다. 희망이 도움이됩니다! –