2017-03-25 26 views
1

dpp의 얼굴 찾기 : http://dlib.net/face_detection_ex.cpp.html 인 cpp 파일을 컴파일하려고했습니다.JPEG_SUPPORT 헤더를 dlib cpp 파일에 포함 할 수 없습니다.

processing image /home/james/Work/Coding/Sources/Image/950.jpg 

exception thrown! 
Unable to load image in file /home/dave/Code/Resources/Images/500.jpg. 
You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG files. 
Do this by following the instructions at http://dlib.net/compile.html. 

Note that you must cause DLIB_JPEG_SUPPORT to be defined for your entire project. 
So don't #define it in one file. Instead, use a compiler switch like -DDLIB_JPEG_SUPPORT 
so it takes effect for your entire application. 

나는 -DDLIB_JPEG_SUPPORT 플래그를 사용하려하고, 그 실패, 그래서 TREID 파일에서 그들을 정의 : 나는 그것을 실행했을 때, 그것은 내가 JPG 및 PNG 파일의 라이브러리를 포함라고했습니다

*/ 

#define DLIB_JPEG_SUPPORT 
#define DLIB_PNG_SUPPORT 

#include </home/james/dlib/image_io.h> 
#include </home/james/dlib/image_processing/frontal_face_detector.h> 
#include </home/james/dlib/gui_widgets.h> 
#include </home/james/dlib/image_io.h> 
#include <iostream> 

using namespace dlib; 
using namespace std; 

// ---------------------------------------------------------------------------------------- 

int main(int argc, char** argv) 

하지만 컴파일하지 못했습니다

[email protected]:~/Work/Coding/Cpp/Dlib/Examples$ g++ -std=c++11 -O3 -I.. ~/dlib/all/source.cpp -lpthread -lX11 face_detection_ex.cpp -o face_detection_ex_2/tmp/ccVHitZj.o: In function `main': 
face_detection_ex.cpp:(.text.startup+0x1c0d): undefined reference to `dlib::jpeg_loader::jpeg_loader(std::string const&)' 
face_detection_ex.cpp:(.text.startup+0x1d0a): undefined reference to `dlib::jpeg_loader::is_gray() const' 
face_detection_ex.cpp:(.text.startup+0x1e3b): undefined reference to `dlib::png_loader::png_loader(std::string const&)' 
face_detection_ex.cpp:(.text.startup+0x1f04): undefined reference to `dlib::png_loader::is_gray() const' 
face_detection_ex.cpp:(.text.startup+0x1f23): undefined reference to `dlib::png_loader::is_gray() const' 
face_detection_ex.cpp:(.text.startup+0x1f38): undefined reference to `dlib::png_loader::is_graya() const' 
face_detection_ex.cpp:(.text.startup+0x1f59): undefined reference to `dlib::png_loader::is_graya() const' 
face_detection_ex.cpp:(.text.startup+0x1f6e): undefined reference to `dlib::png_loader::is_rgb() const' 
face_detection_ex.cpp:(.text.startup+0x1f83): undefined reference to `dlib::png_loader::is_rgb() const' 
face_detection_ex.cpp:(.text.startup+0x1f98): undefined reference to `dlib::png_loader::is_rgba() const' 
face_detection_ex.cpp:(.text.startup+0x1fad): undefined reference to `dlib::png_loader::is_rgba() const' 
face_detection_ex.cpp:(.text.startup+0x2009): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x20b6): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x211c): undefined reference to `dlib::png_loader::~png_loader()' 
face_detection_ex.cpp:(.text.startup+0x229a): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x2587): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x2ea7): undefined reference to `dlib::png_loader::~png_loader()' 
face_detection_ex.cpp:(.text.startup+0x2fe9): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x30ac): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x313c): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
face_detection_ex.cpp:(.text.startup+0x31c4): undefined reference to `dlib::png_loader::get_row(unsigned int) const' 
collect2: error: ld returned 1 exit status 

답변

3

전에 질문 컴파일러와 툴을 보여 오류 및 제안 메시지를 읽을 문의하십시오.

About:
exception thrown! Unable to load image in file /home/dave/Code/Resources/Images/500.jpg. You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG files. Do this by following the instructions at http://dlib.net/compile.html .

libjpeg,의 libpng 등 라이브러리를 설치하고 프로그램을 링크 컴파일 시간에 그들을 사용합니다. 제안 된 페이지 http://dlib.net/compile.html을 읽으십시오.

소스 코드 파일이 여러 개있는 경우 컴파일 전에 코드에서 전 처리기 지시문을 삭제하십시오.

#define DLIB_JPEG_SUPPORT 
#define DLIB_PNG_SUPPORT 

스위치 컴파일러 -DDLIB_JPEG_SUPPORT를 사용하십시오.

Note that you must cause DLIB_JPEG_SUPPORT to be defined for your entire project. So don't #define it in one file. Instead, use a compiler switch like -DDLIB_JPEG_SUPPORT so it takes effect for your entire application.

그래서,이 같은 사용 명령은 컴파일 :

g++ face_detection_ex.cpp -o face_detection_ex_2 -std=c++11 -O3 -I.. ~/dlib/all/source.cpp -lpthread -lX11 -ljpeg -lpng -DDLIB_JPEG_SUPPORT -DDLIB_PNG_SUPPORT

가정 라이브러리 (libjpeg과의 libpng)가 이미 설치되어 있습니다.

+0

나는 그들을 정의하려고 시도했지만 작동하지 않았다. 이미 libjpeg 및 libpng가 설치되어 있습니다. – Rich

+0

명령을 실행하려고했을 때 다음과 같이 말했습니다 :'g ++ : error : lpng : No such file or directory' – Rich

+1

나는 명령에서 대쉬를 잊어 버렸지 만 지금은 업데이트되었습니다. 변경 (lpng -> - lpng). – jplc