How should I run this ordinary example from DLIB-C++?

How should I run this ordinary example from DLIB-C++?

I am too new in DLIB-C++ and I decided to run the following example on my Ubuntu 16.04. However, I receive the following errors. What is the solution? And what if I want to run all the examples of C++ from this site?

The example is:

// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*

    This is an example illustrating the use of the perspective_window tool
    in the dlib C++ Library.  It is a simple tool for displaying 3D point 
    clouds on the screen.

*/

#include <dlib/gui_widgets.h>
#include <dlib/image_transforms.h>
#include <cmath>

using namespace dlib;
using namespace std;

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

int main()
{
    // Let's make a point cloud that looks like a 3D spiral.
    std::vector<perspective_window::overlay_dot> points;
    dlib::rand rnd;
    for (double i = 0; i < 20; i+=0.001)
    {
        // Get a point on a spiral
        dlib::vector<double> val(sin(i),cos(i),i/4);

        // Now add some random noise to it
        dlib::vector<double> temp(rnd.get_random_gaussian(),
                                    rnd.get_random_gaussian(),
                                    rnd.get_random_gaussian());
        val += temp/20;

        // Pick a color based on how far we are along the spiral
        rgb_pixel color = colormap_jet(i,0,20);

        // And add the point to the list of points we will display
        points.push_back(perspective_window::overlay_dot(val, color));
    }

    // Now finally display the point cloud.
    perspective_window win;
    win.set_title("perspective_window 3D point cloud");
    win.add_overlay(points);
    win.wait_until_closed();
}

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

The errors are:

In file included from /usr/include/dlib/gui_core/xlib.h:4,
                from /usr/include/dlib/gui_core.h:14,
                 from /usr/include/dlib/gui_widgets/drawable.h:8,
                from /usr/include/dlib/gui_widgets/widgets.h:9,
               from /usr/include/dlib/gui_widgets.h:8,
                 from avval.cpp:10:
 /usr/include/dlib/gui_core/gui_core_kernel_2.h:11:2: error: #error "DLIB_NO_GUI_SUPPORT is defined so you can't use the GUI code.  Turn DLIB_NO_GUI_SUPPORT off if you want to use it."
  #error "DLIB_NO_GUI_SUPPORT is defined so you can't use the GUI code.  Turn DLIB_NO_GUI_SUPPORT off if you want to use it."
    ^~~~~  /usr/include/dlib/gui_core/gui_core_kernel_2.h:12:2: error: #error "Also make sure you have libx11-dev installed on your system"
  #error "Also make sure you have libx11-dev installed on your system"

I will be waiting for your kind advice.

相关内容