c++ – Thrust thrust::system::tbb::par Compiling Error

I’m new to CUDA programming. Since memory allocation time is very high, I’m trying to use Thrust with lambda function in the .cpp file. My question is about execution policy of Thrust.

If I use thrust::system::cpp::par as an execution policy, the codes below works well, but when I try to use thrust::system::tbb::par, I get compiling error:

/usr/bin/ld: CMakeFiles/darknet_ros_msgs.dir/src/camera_projection.cpp.o: undefined reference to symbol '_ZN3tbb18task_group_contextD1Ev'
//usr/lib/x86_64-linux-gnu/libtbb.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/darknet_ros_msgs.dir/build.make:487: recipe for target 'devel/lib/darknet_ros_msgs/darknet_ros_msgs' failed
make(3): *** (devel/lib/darknet_ros_msgs/darknet_ros_msgs) Error 1
CMakeFiles/Makefile2:275: recipe for target 'CMakeFiles/darknet_ros_msgs.dir/all' failed
make(2): *** (CMakeFiles/darknet_ros_msgs.dir/all) Error 2
CMakeFiles/Makefile2:282: recipe for target 'CMakeFiles/darknet_ros_msgs.dir/rule' failed
make(1): *** (CMakeFiles/darknet_ros_msgs.dir/rule) Error 2
Makefile:195: recipe for target 'darknet_ros_msgs' failed
make: *** (darknet_ros_msgs) Error 2

My codes:

thrust::host_vector<bool> vec_in_image_bool(N);

Cloud::Ptr result_cloud(new Cloud);

auto ff = (this,img_width, img_height, mat_point_transformer, interested_detections, id, result_cloud)(const Point &p) -> bool {

    const double& distance = sqrt(pow(p.x, 2) + pow(p.y, 2));

    if (distance <= 0.2)
        return false;

    double r0 = mat_point_transformer.matrix().coeff(0,0) * p.x + mat_point_transformer.matrix().coeff(0,1) * p.y
                + mat_point_transformer.matrix().coeff(0,2) * p.z + mat_point_transformer.matrix().coeff(0,3) * 1;
    double r1 = mat_point_transformer.matrix().coeff(1,0) * p.x + mat_point_transformer.matrix().coeff(1,1) * p.y
                + mat_point_transformer.matrix().coeff(1,2) * p.z + mat_point_transformer.matrix().coeff(1,3) * 1;
    double r2 = mat_point_transformer.matrix().coeff(2,0) * p.x + mat_point_transformer.matrix().coeff(2,1) * p.y
                + mat_point_transformer.matrix().coeff(2,2) * p.z + mat_point_transformer.matrix().coeff(2,3) * 1;

    if (r2 <= 0)
        return false;

    int point_in_image_x = (int) (r0 / r2);
    int point_in_image_y = (int) (r1 / r2);


    if (point_in_image_x < 0|| point_in_image_y < 0 || point_in_image_x >= img_width || point_in_image_y >= img_height)
        return false;

    //result_cloud->points.push_back(p);

    for (size_t j = 0; j < interested_detections.detections.size(); ++j)
    {

        const auto &detection = interested_detections.detections(j);
        auto bbox = detection.bbox;

        const auto &bbox_orig = bbox;
        auto new_bbox = bbox;

        float scale_factor;
        if (id == 8 || id == 9) {
            scale_factor = 1.0;
        } else {
            scale_factor = 1.66666;
        }

        new_bbox.center.x *= scale_factor;
        new_bbox.center.y *= scale_factor;
        new_bbox.size_x *= scale_factor;
        new_bbox.size_y *= scale_factor;

        double re_align_size = 5;

        double x_min = new_bbox.center.x - new_bbox.size_x / 2;
        x_min = ((x_min - re_align_size) >= 0 ? (x_min - re_align_size) : 0);
        double x_max = new_bbox.center.x + new_bbox.size_x / 2;
        x_max = ((x_max + re_align_size) >= img_width ? img_width : (x_max + re_align_size));
        double y_min = new_bbox.center.y - new_bbox.size_y / 2;
        y_min = ((y_min - re_align_size) > 0 ? (y_min - re_align_size) : 0);
        double y_max = new_bbox.center.y + new_bbox.size_y / 2;
        y_max = ((y_max + re_align_size) > img_height ? img_height : (y_max + re_align_size));

        bool in_detection = point_in_image_x > x_min &&
                point_in_image_y > y_min &&
                point_in_image_x < x_max &&
                point_in_image_y < y_max;

        if(in_detection)
            result_cloud->points.push_back(p);
    }

    return true;
};

thrust::transform(thrust::system::tbb::par,cloud_in->points.begin(),cloud_in->points.end(),vec_in_image_bool.begin(),ff);