dlib cpp文件中不能包含JPEG_SUPPORT标头 [英] Can't include the JPEG_SUPPORT headers in a dlib cpp file

查看:113
本文介绍了dlib cpp文件中不能包含JPEG_SUPPORT标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译一个cpp文件:dlib中的面部查找器: http:// dlib .net / face_detection_ex.cpp.html 。但是当我运行它时,它说我必须包括jpg和png文件的库:

I was trying to compile a cpp file: the face-finder in dlib: http://dlib.net/face_detection_ex.cpp.html. But when I ran it, it said I had to include the libraries for jpg and png files:

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 标志,但是失败了,所以我很想在文件中定义它们:

I tried to use the -DDLIB_JPEG_SUPPORT flag, and that failed, so I treid to define them in the file:

*/

#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)

但这不能编译:

james@james-Toshiba-Satellite-8505:~/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


推荐答案

请在提出问题之前,先阅读一下编译器和工具向您显示的错误和建议消息。

Please before ask a question read the error and suggestion messages that compiler and tools show you.


关于:
抛出异常!无法在文件
/home/dave/Code/Resources/Images/500.jpg中加载图像。您必须#define
DLIB_JPEG_SUPPORT并链接到libjpeg才能读取JPEG文件。按照 http://dlib.net/compile.html 上的说明,通过
进行此操作

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

Install libjpeg, libpng, etc. libraries and use them at compilation time to link the program. Please read the suggested page http://dlib.net/compile.html.

在编译之前,如果您有多个源代码文件,请从代码中删除预处理器指令。

Before compile delete the preprocessor directives from your code if you have several source code files.

#define DLIB_JPEG_SUPPORT
#define DLIB_PNG_SUPPORT

并使用建议的开关编译器:-DDLIB_JPEG_SUPPORT。

and use the suggested switch compiler: -DDLIB_JPEG_SUPPORT.


请注意,必须使整个
项目都定义DLIB_JPEG_SUPPORT。因此,请勿#define它在一个文件中。而是使用像-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.

因此,请使用如下命令进行编译:

So, use command like this to compile:


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

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)。

Assuming libraries (libjpeg and libpng) have been already installed.

这篇关于dlib cpp文件中不能包含JPEG_SUPPORT标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆