title: Can't include the JPEG_SUPPORT headers in a dlib cpp file
body: <p>I was trying to compile a cpp file: the face-finder in dlib: <a href="http://dlib.net/face_detection_ex.cpp.html" rel="nofollow noreferrer">http://dlib.net/face_detection_ex.cpp.html</a>. But when I ran it, it said I had to include the libraries for jpg and  png files: </p>
  
  <pre><code>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.
  </code></pre>
  
  <p>I tried to use the <code>-DDLIB_JPEG_SUPPORT</code> flag, and that failed, so I treid to define them in the file:</p>
  
  <pre><code>*/
  
  #define DLIB_JPEG_SUPPORT
  #define DLIB_PNG_SUPPORT
  
  #include &lt;/home/james/dlib/image_io.h&gt;
  #include &lt;/home/james/dlib/image_processing/frontal_face_detector.h&gt;
  #include &lt;/home/james/dlib/gui_widgets.h&gt;
  #include &lt;/home/james/dlib/image_io.h&gt;
  #include &lt;iostream&gt;
  
  using namespace dlib;
  using namespace std;
  
  // ----------------------------------------------------------------------------------------
  
  int main(int argc, char** argv)
  </code></pre>
  
  <p>but that failed to compile:</p>
  
  <pre><code>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&amp;)'
  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&amp;)'
  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
  </code></pre>