Ошибка при использовании tbb::rallel_for

У меня ошибка, когда я использую parallel_for библиотеки TBB. Я не могу понять, почему.. Я был в состоянии использовать tbb:: atomic, поэтому я предполагаю, что это не проблема линковки. Вот часть моего кода, где я использую TBB:

auto values = std::vector<double>(10);

    tbb::parallel_for( tbb::blocked_range<int>(0,values.size()),
                       [&](tbb::blocked_range<int> r)
    {
        for (int i=r.begin(); i<r.end(); ++i)
        {
            values[i] = std::sin(i * 0.001);
        }
    });

    double total = 0;

    for (double value : values)
    {
        total += value;
    }

    std::cout << total << std::endl;

Я взял несколько примеров в Интернете, чтобы легче отлаживать. Вот мои включения, я пытался добавить tbb::task, но это не сработало.

#include "interval_map_estimator.h"
#include "interval_map_estimation.h"
#include <stdlib.h>
#include <boost/numeric/ublas/matrix.hpp>

//Antoine
#include <chrono>
#include <boost/thread/thread.hpp>
#include <tbb/parallel_for.h>
#include <tbb/task.h>
#include <iostream>

И здесь из двух ошибок, которые я получаю (они одинаковы)

    /home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::start_for<tbb::blocked_range<int>, IntervalMapEstimation::IntervalMapEstimator::extract_relevant_points_multithread(std::vector<IntervalMapEstimation::Point3D, std::allocator<IntervalMapEstimation::Point3D> >&, std::vector<IntervalMapEstimation::Point3D, std::allocator<IntervalMapEstimation::Point3D> >&, double, double)::{lambda(tbb::blocked_range<int>)#1}, tbb::auto_partitioner const>::run(tbb::blocked_range<int> const&, {lambda(tbb::blocked_range<int>)#1} const&, tbb::auto_partitioner&)':
/usr/include/tbb/parallel_for.h:87: undefined reference to `tbb::task_group_context::~task_group_context()'
/usr/include/tbb/parallel_for.h:87: undefined reference to `tbb::task_group_context::~task_group_context()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro+0x18): undefined reference to `typeinfo for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task_group_context::task_group_context(tbb::task_group_context::kind_type, unsigned long)':
/usr/include/tbb/task.h:450: undefined reference to `tbb::task_group_context::init()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::task()':
/usr/include/tbb/task.h:556: undefined reference to `vtable for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::~task()':
/usr/include/tbb/task.h:560: undefined reference to `vtable for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::is_cancelled() const':
/usr/include/tbb/task.h:862: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator new(unsigned long, tbb::internal::allocate_root_with_context_proxy const&)':
/usr/include/tbb/task.h:1005: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator delete(void*, tbb::internal::allocate_root_with_context_proxy const&)':
/usr/include/tbb/task.h:1009: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator new(unsigned long, tbb::internal::allocate_continuation_proxy const&)':
/usr/include/tbb/task.h:1014: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator delete(void*, tbb::internal::allocate_continuation_proxy const&)':
/usr/include/tbb/task.h:1018: undefined reference to `tbb::internal::allocate_continuation_proxy::free(tbb::task&) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::allocate_sibling(tbb::task*, unsigned long)':
/usr/include/tbb/parallel_for.h:120: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::adaptive_mode<tbb::interface9::internal::auto_partition_type>::adaptive_mode()':
/usr/include/tbb/partitioner.h:272: undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro._ZTVN3tbb10interface98internal9flag_taskE[_ZTVN3tbb10interface98internal9flag_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro._ZTIN3tbb10interface98internal9flag_taskE[_ZTIN3tbb10interface98internal9flag_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
collect2: error: ld returned 1 exit status

Если у вас есть какие-либо предложения, это будет очень приветствоваться:)

0 ответов

Другие вопросы по тегам